How to use the object-hash.sha1 function in object-hash

To help you get started, we’ve selected a few object-hash 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 bhoov / exbert / client / src / ts / api / mainApi.ts View on Github external
function checkDemoAPI(toSend, backupUrl = null, backupPayload = null) {
    const hsh = hash.sha1(toSend);
    console.log("CHECKING DEMOAPI: " + hsh);
    if (DemoAPI.hasOwnProperty(hsh)) {
        // Relies on a symbolic link being present in the dist folder to the demo folder
        const path = './demo/' + DemoAPI[hsh]
        console.log("TRYING TO SENDING STATIC: ", path);
        const follow = (response) => responseJson(response, backupUrl, backupPayload)
        return fetch(path).then(follow)
    }
    return d3.json(backupUrl, backupPayload)
}
github serverless / serverless / lib / plugins / aws / provider / awsProvider.js View on Github external
request(service, method, params, options) {
    const that = this;
    const credentials = Object.assign({}, that.getCredentials());
    // Make sure options is an object (honors wrong calls of request)
    const requestOptions = _.isObject(options) ? options : {};
    const shouldCache = _.get(requestOptions, 'useCache', false);
    const paramsWithRegion = _.merge({}, params, {
      region: _.get(options, 'region'),
    });
    const paramsHash = objectHash.sha1(paramsWithRegion);
    const MAX_TRIES = 4;
    const persistentRequest = f =>
      new BbPromise((resolve, reject) => {
        const doCall = numTry => {
          f()
            // We're resembling if/else logic, therefore single `then` instead of `then`/`catch` pair
            .then(resolve, e => {
              if (
                numTry < MAX_TRIES &&
                e.statusCode !== 403 && // Invalid credentials
                ((e.providerError && e.providerError.retryable) || e.statusCode === 429)
              ) {
                that.serverless.cli.log(
                  _.join(
                    [
                      `Recoverable error occurred (${e.message}), sleeping for 5 seconds.`,
github juicycleff / ultimate-backend / libs / nest-multi-tenant / src / database / mongo / mongo-core.module.ts View on Github external
useFactory: async (
        connections: Map,
        mongoModuleOptions: MongoModuleOptions,
      ) => {
        const { uri, clientOptions } = mongoModuleOptions;
        const key = hash.sha1({
          uri,
          clientOptions,
        });
        if (connections.has(key)) {
          return connections.get(key);
        }
        const client = new MongoClient(
          uri,
          clientOptions || DEFAULT_MONGO_CLIENT_OPTIONS,
        );
        connections.set(key, client);
        return await client.connect();
      },
      inject: [getContainerToken(mongoContainerName), MONGO_MODULE_OPTIONS],
github soajs / soajs.dashboard / lib / ci / index.js View on Github external
parseYaml: function (req, config, mainCb, provider, yaml, cb) {
		try {
			var jsonYaml = yamljs.parse(yaml);
			var sha = hash.sha1(jsonYaml);
		}
		catch (e) {
			req.soajs.log.error(e);
			return mainCb({"code": 984, "msg": config.errors[984]});
		}
		if (typeof jsonYaml !== "object") {
			return mainCb({"code": 984, "msg": config.errors[984]});
		}

		switch (provider) {
			case 'travis':
				if (!(jsonYaml && jsonYaml.after_success)) {
					jsonYaml.after_success = [];
				}
				if (jsonYaml && jsonYaml.after_success && jsonYaml.after_success.indexOf("node ./soajs.cd.js") === -1) {
					jsonYaml.after_success.push("node ./soajs.cd.js");
github volga-volga / react-native-animated-map-clusters / src / ClusteringMap.js View on Github external
calcClusters(region: Region) {
    const MIN_DISTANCE = convertPtInDistance(region, this.props.minDistance || 30, this.mapHeight);
    this.MIN_DISTANCE_SQR = MIN_DISTANCE * MIN_DISTANCE;
    const clusters = this.calc(new Array(this.getChildren().length).fill(1)
      .map((i, index) => [index]));
    const clusterInfo = [];
    for (let i = 0; i < clusters.length; ++i) {
      const clusterCenter = calcCenter(clusters[i].map(k => this.getChildren()[k].props.coordinate));
      clusterInfo.push({
        center: clusterCenter,
        points: clusters[i],
        hash: hash.sha1(clusters[i]),
      });
    }
    return clusterInfo;
  }
github adobe / helix-cli / src / strain-config-utils.js View on Github external
function name(strain) {
  if (strain) {
    return hash.sha1(strain).substr(24);
  }
  return null;
}
github patrickmichalina / fusebox-angular-universal-starter / src / client / app / shared / services / injection.service.ts View on Github external
createElement(renderer: Renderer2, injectable: DOMInjectable): T | undefined {
    if (!injectable || !injectable.element) return undefined
    const elm = renderer.createElement(injectable.element) as T
    const id = sha1(JSON.stringify(injectable))

    renderer.setProperty(elm, 'id', id)
    if (injectable.value) renderer.setValue(elm, injectable.value)

    Object.keys(injectable.attributes || {})
      .forEach(key => renderer.setAttribute(elm, key, (injectable.attributes || {})[key] as any))

    return elm
  }

object-hash

Generate hashes from javascript objects in node and the browser.

MIT
Latest version published 3 years ago

Package Health Score

74 / 100
Full package analysis