How to use safe-stable-stringify - 7 common examples

To help you get started, we’ve selected a few safe-stable-stringify examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github neo-one-suite / neo-one / packages / neo-one-smart-contract-compiler / src / compile / helper / function / GetCallableHelper.ts View on Github external
public static getKey(options: GetCallableHelperOptions = { bindThis: false }): string {
    const bindThis = options.bindThis || false;
    const overwriteThis = options.overwriteThis || false;

    return stringify({ bindThis, overwriteThis });
  }
github neo-one-suite / neo-one / packages / neo-one-editor-server / src / resolveDependencies.ts View on Github external
export async function resolveDependencies(dependencies: Dependencies): Promise {
  const key = stringify(dependencies);
  const resolved = resolutionCache.get(key);
  if (resolved !== undefined) {
    return resolved;
  }

  const result = new Resolver().resolve(dependencies);
  result.catch((err) => {
    editorLogger.error({ name: 'resolve_dependencies_final_error', err });

    cache.del(key);
  });
  resolutionCache.set(key, result);

  return result;
}
github neo-one-suite / neo-one / packages / neo-one-smart-contract-compiler / src / compile / helper / function / InvokeCallHelper.ts View on Github external
public static getKey(options: InvokeCallHelperOptions = { bindThis: false, noArgs: false }): string {
    const bindThis = options.bindThis || false;
    const overwriteThis = options.overwriteThis || false;
    const noArgs = options.noArgs || false;

    return stringify({ bindThis, overwriteThis, noArgs });
  }
github neo-one-suite / neo-one / packages / neo-one-smart-contract-codegen / src / contract / genContract.ts View on Github external
readonly abiPath: string;
  readonly sourceMapsPath: string;
  readonly networksDefinition: SmartContractNetworksDefinition;
}) => {
  const relativeTypes = getRelativeImport(createContractPath, typesPath);
  const smartContract = getSmartContractName(name);
  const relativeABI = getRelativeImport(createContractPath, abiPath);
  const relativeSourceMaps = getRelativeImport(createContractPath, sourceMapsPath);
  const abiName = getABIName(name);

  return {
    js: `import { ${abiName} } from '${relativeABI}';
import { sourceMaps } from '${relativeSourceMaps}';

const definition = {
  networks: ${stringify(networksDefinition, undefined, 2)},
  abi: ${abiName},
  sourceMaps,
};

export const ${getCreateSmartContractName(name)} = (
  client,
) => client.smartContract(definition);
  `,
    ts: `
import { Client } from '@neo-one/client';
import { ${smartContract} } from '${relativeTypes}';
import { ${abiName} } from '${relativeABI}';
import { sourceMaps } from '${relativeSourceMaps}';

const definition = {
  networks: ${stringify(networksDefinition, undefined, 2)},
github neo-one-suite / neo-one / packages / neo-one-smart-contract-codegen / src / abi / genABI.ts View on Github external
export const genABI = (name: string, abi: ABI) => ({
  js: `export const ${getABIName(name)} = ${stringify(abi, undefined, 2)};`,
  ts: `import { ABI } from '@neo-one/client';

export const ${getABIName(name)}: ABI;
`,
});
github neo-one-suite / neo-one / packages / neo-one-local-browser / src / filesystem / worker / registerWorkerPouch.ts View on Github external
const liveChanges = (args: RequestArgs, messageID: string) => {
        const options = args[0];
        const key = stringify(options);
        let changesIn = allChanges.get(key);
        if (changesIn === undefined) {
          changesIn = db.changes(options);
          allChanges.set(key, changesIn);
        }

        const changes = changesIn;
        allChangesUsers.set(key, getChangesUserCount(key) + 1);

        const onChange = (change: any) => {
          postMessage('update', messageID, change);
        };

        const onComplete = (change: any) => {
          sendSuccess(messageID, change);
          removeChanges(messageID);

safe-stable-stringify

Deterministic and safely JSON.stringify to quickly serialize JavaScript objects

MIT
Latest version published 3 months ago

Package Health Score

79 / 100
Full package analysis

Popular safe-stable-stringify functions