How to use imurmurhash - 10 common examples

To help you get started, we’ve selected a few imurmurhash 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 codefresh-io / zenkube / client / src / js / ui / react_component / robohash.js View on Github external
export default (obj = {}) => {

    let
        defaultObj = defaults(obj, { width: 45, height: 45 }),
        hashedId = MurmurHash3(obj["id"]).result();

    return img(
       Object.assign(
            {
                src: `https://robohash.org/${hashedId.toString(16)}.png?size=${at(obj, 'width', 'height').join('x')}`,
                style: { backgroundColor: _.get(RAINBOW_COLORS, ~~(hashedId / MAX_HASH * RAINBOW_COLORS.length)) }
            },
            omit(defaultObj, 'src') // "..." object expander is a late es6 addition
        )
    );
};
github markfinger / unfort / src / env-hash / env-hash.js View on Github external
export function hashFileSystemDataLists(data) {
  if (!data.length) {
    return '';
  }

  const hash = new Murmur(data[0][0]);

  data.forEach((entry, i) => {
    // On the first iteration, skip the first cell as we applied it above
    if (i !== 0) {
      hash.hash(entry[0]);
    }
    hash.hash(String(entry[1]));
  });

  return hash.result();
}
github markfinger / unfort / src / hash-npm-dependency-tree / hash_npm_dependency_tree.js View on Github external
], (err, data) => {
    if (err) return cb(err);

    const [packageJson, dirs] = data;
    const hash = murmur(packageJson);

    async.map(
      dirs,
      (dir, cb) => {
        const dirname = path.join(rootNodeModules, dir);
        fs.stat(dirname, cb)
      },
      (err, stats) => {
        if (err) return cb(err);

        stats.forEach((stat, i) => {
          const dir = dirs[i];
          const mtime = stat.mtime.getTime();
          hash.hash(dir + mtime);
        });
github steelbrain / pundle / packages / pundle-api / src / Context.js View on Github external
getFileChunk(entry: string, label: ?string = null): ChunkFile {
    let generatedLabel = label
    if (!generatedLabel) {
      generatedLabel = new Imurmurhash()
        .hash(entry)
        .result()
        .toString()
    }
    return {
      type: 'file',
      format: path.extname(entry),
      entry,
      label: generatedLabel,
      imports: [],
    }
  }
  async report(report: Object): Promise {
github steelbrain / pundle / packages / pundle-api / src / Context.js View on Github external
getSimpleChunk(entry: ?string = null, imports: Array = [], label: ?string = null): ChunkSimple {
    let generatedLabel = label
    if (!generatedLabel) {
      if (entry) {
        generatedLabel = new Imurmurhash()
          .hash(entry)
          .result()
          .toString()
      } else {
        throw new Error('Either entry or label are required to make a chunk')
      }
    }

    return {
      type: 'simple',
      format: '.js',
      entry,
      label: generatedLabel,
      imports,
    }
  }
github markfinger / unfort / src / kv-cache / utils.js View on Github external
    .map(entry => new Murmur(entry.toString()).result())
    .join('_');
github codefresh-io / zenkube / client / src / js / main.js View on Github external
.map(({ timestamp, event: { object: { spec } } })=>({
                            create: new Date(timestamp),
                            hash: MurmurHash3(JSON.stringify(spec)).result(),
                            spec
                        }))
                        .reduce((ac, cur)=> _.get(_.last(ac), 'hash') !== cur["hash"] ? ac.concat([cur]) : ac, [])
github Soluto / dynamico / server / driver / lib / index.ts View on Github external
async registerHost(dependencies: Dependencies = {}): Promise {
    let result: Maybe = undefined;

    const sortedDependencies = Object.entries(dependencies).sort(([nameA], [nameB]) => nameA.localeCompare(nameB));
    const id = MurmurHash3(JSON.stringify(sortedDependencies)).result();

    const index = await this.storage.getIndex();

    if (!index[id]) {
      result = await this.upsertIndex({
        id,
        dependencies
      });
    }

    return {
      id,
      issues: result ? result.issues : {},
      index: result ? result.index : index[id].components
    };
  }
github markfinger / unfort / src / kv-cache / utils.js View on Github external
export function generateMurmurHash(key) {
  if (!isArray(key)) {
    return String(new Murmur(key.toString()).result());
  }

  if (!key.length) {
    throw new Error('Key array does not contain any entries');
  }

  return key
    .map(entry => new Murmur(entry.toString()).result())
    .join('_');
}
github markfinger / unfort / src / kv-cache / utils.js View on Github external
export function murmurFilename(cacheKey) {
  const hash = murmur(cacheKey).result();
  return hash + '.json';
}

imurmurhash

An incremental implementation of MurmurHash3

MIT
Latest version published 11 years ago

Package Health Score

67 / 100
Full package analysis

Popular imurmurhash functions