* Creates a new [[Interface]] from the ABI %%value%%. * * The %%value%% may be provided as an existing [[Interface]] object, * a JSON-encoded ABI or any Human-Readable ABI format.
(value)
| 956 | * a JSON-encoded ABI or any Human-Readable ABI format. |
| 957 | */ |
| 958 | static from(value) { |
| 959 | // Already an Interface, which is immutable |
| 960 | if (value instanceof Interface) { |
| 961 | return value; |
| 962 | } |
| 963 | // JSON |
| 964 | if (typeof (value) === "string") { |
| 965 | return new Interface(JSON.parse(value)); |
| 966 | } |
| 967 | // Maybe an interface from an older version, or from a symlinked copy |
| 968 | if (typeof (value.format) === "function") { |
| 969 | return new Interface(value.format("json")); |
| 970 | } |
| 971 | // Array of fragments |
| 972 | return new Interface(value); |
| 973 | } |
| 974 | } |
no test coverage detected