util#isDeepStrictEqual TypeScript Examples

The following examples show how to use util#isDeepStrictEqual. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: manifestManager.ts    From flatpak-vscode with MIT License 6 votes vote down vote up
/**
     * Update the manifest at the specified uri
     * @param uri Where the concerned manifest is stored
     */
    private async updateManifest(uri: vscode.Uri) {
        const manifests = await this.getManifests()
        const oldManifest = manifests.get(uri)

        if (oldManifest === undefined) {
            return
        }

        try {
            const updatedManifest = await parseManifest(uri)
            if (updatedManifest === null) {
                return
            }

            manifests.delete(oldManifest.uri)
            manifests.add(updatedManifest)

            if (uri.fsPath === this.activeManifest?.uri.fsPath) {
                await this.setActiveManifest(updatedManifest, false)
            }

            const hasModifiedModules = !isDeepStrictEqual(oldManifest.manifest.modules, updatedManifest.manifest.modules)
            const hasModifiedBuildOptions = !isDeepStrictEqual(oldManifest.manifest['build-options'], updatedManifest.manifest['build-options'])

            if (hasModifiedModules || hasModifiedBuildOptions) {
                console.log('Updated manifest has modified modules or build-options. Requesting a rebuild')
                this._onDidRequestRebuild.fire(updatedManifest)
            }
        } catch (err) {
            console.warn(`Failed to parse manifest at ${uri.fsPath}`)
        }
    }
Example #2
Source File: transaction-manager.ts    From hoprnet with GNU General Public License v3.0 6 votes vote down vote up
/**
   * If a transaction payload exists in mined or pending with a higher/equal gas price
   * @param payload object
   * @param maxPrority Max Priority Fee. Tips paying to the miners, which correlates to the likelyhood of getting transactions included.
   * @returns [true if it exists, transaction hash]
   */
  public existInMinedOrPendingWithHigherFee(payload: TransactionPayload, maxPrority: BigNumber): [boolean, string] {
    // Using isDeepStrictEqual to compare TransactionPayload objects, see
    // https://nodejs.org/api/util.html#util_util_isdeepstrictequal_val1_val2
    const index = Array.from(this.payloads.values()).findIndex((pl) => isDeepStrictEqual(pl, payload))
    if (index < 0) {
      return [false, '']
    }

    const hash = Array.from(this.payloads.keys())[index]
    if (
      !this.mined.get(hash) &&
      BigNumber.from((this.pending.get(hash) ?? this.queuing.get(hash)).maxPrority).lt(maxPrority)
    ) {
      return [false, hash]
    }
    return [true, hash]
  }
Example #3
Source File: plugin.ts    From vscode-microprofile with Apache License 2.0 6 votes vote down vote up
export function handleExtensionChange(extensions: readonly vscode.Extension<any>[]): void  {
  if (!existingExtensions) {
    return;
  }
  const oldExtensions = new Set(existingExtensions.slice());
  const newExtensions = collectMicroProfileJavaExtensions(extensions);
  let hasChanged = (oldExtensions.size !== newExtensions.length);
  if (!hasChanged) {
    for (const newExtension of newExtensions) {
      let found = false;
      for (const oldExtension of oldExtensions) {
        if (isDeepStrictEqual(oldExtension, newExtension)) {
          found = true;
          break;
        }
      }
      if (found) {
        continue;
      } else {
        hasChanged = true;
        break;
      }
    }
  }

  if (hasChanged) {
    const msg = `Extensions to the MicroProfile Language Server changed, reloading ${vscode.env.appName} is required for the changes to take effect.`;
    const action = 'Reload';
    vscode.window.showWarningMessage(msg, action).then((selection) => {
      if (action === selection) {
        vscode.commands.executeCommand(Commands.RELOAD_WINDOW);
      }
    });
  }
}
Example #4
Source File: manifestManager.ts    From flatpak-vscode with MIT License 5 votes vote down vote up
isActiveManifest(manifest: Manifest | null): boolean {
        return isDeepStrictEqual(this.activeManifest, manifest)
    }
Example #5
Source File: equal.ts    From common-ts with MIT License 5 votes vote down vote up
equal = (a: any, b: any) => isDeepStrictEqual(a, b)
Example #6
Source File: getQuote.ts    From stellar-anchor-tests with Apache License 2.0 4 votes vote down vote up
canFetchQuote: Test = {
  sep: 38,
  assertion: "can fetch an existing quote",
  group: "GET /quote",
  dependencies: [returnsValidJwt, canCreateQuote],
  context: {
    expects: {
      token: undefined,
      quoteServerUrl: undefined,
      sep38QuoteResponseObj: undefined,
    },
    provides: {},
  },
  failureModes: {
    INVALID_SCHEMA: {
      name: "invalid GET /quote schema",
      text(args: any): string {
        return (
          "The response body from GET /quote does not match the schema defined by the protocol. " +
          "Errors:\n\n" +
          `${args.errors}`
        );
      },
      links: {
        "GET /prices Response":
          "https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0038.md#response-4",
      },
    },
    QUOTE_BODY_DOESNT_MATCH: {
      name: "quote response bodies don't match",
      text(args: any): string {
        return (
          "The response body returned from POST /quote does not match the response body returned from " +
          `GET /quote:\n\nExpected:\n${JSON.stringify(
            args.expectedBody,
            null,
            2,
          )}\n\nActual:\n` +
          `${JSON.stringify(args.actualBody, null, 2)}`
        );
      },
    },
    ...genericFailures,
  },
  async run(_config: Config): Promise<Result> {
    const result: Result = { networkCalls: [] };
    const networkCall: NetworkCall = {
      request: new Request(
        this.context.expects.quoteServerUrl +
          "/quote/" +
          this.context.expects.sep38QuoteResponseObj.id,
        {
          headers: { Authorization: `Bearer ${this.context.expects.token}` },
        },
      ),
    };
    result.networkCalls.push(networkCall);
    const quoteResponse = await makeRequest(
      networkCall,
      200,
      result,
      "application/json",
    );
    if (!quoteResponse) return result;
    const validationResult = validate(quoteResponse, quoteSchema);
    if (validationResult.errors.length !== 0) {
      result.failure = makeFailure(this.failureModes.INVALID_SCHEMA, {
        errors: validationResult.errors.join("\n"),
      });
      return result;
    }
    if (
      !isDeepStrictEqual(
        this.context.expects.sep38QuoteResponseObj,
        quoteResponse,
      )
    ) {
      result.failure = makeFailure(this.failureModes.QUOTE_BODY_DOESNT_MATCH, {
        expectedBody: this.context.expects.sep38QuoteResponseObj,
        actualBody: quoteResponse,
      });
      return result;
    }
    return result;
  },
}