How to use xxhashjs - 10 common examples

To help you get started, we’ve selected a few xxhashjs 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 byte-foundry / prototypo / app / scripts / actions / lite.actions.jsx View on Github external
localClient = LocalClient.instance();
	localServer = LocalServer.instance;
	undoWatcher = new BatchUpdate(
		undoableStore,
		'/undoableStore',
		'controlsValues',
		localClient,
		localServer.lifespan,
		name => `${name} modification`,
		(headJS) => {
			debouncedSave(headJS.controlsValues);
		},
	);
});

const hasher = XXHash(0xdeadbeef);

export default {
	'/create-step': async ({name, description, choice}) => {
		// check if everything correct with the form
		if (name === undefined || name === '' || String(name).trim() === '') {
			const patch = prototypoStore
				.set('errorAddStep', 'You must choose a name for your step')
				.commit();

			localServer.dispatchUpdate('/prototypoStore', patch);
			return;
		}
		// done checking if everything is correct with the form

		// create new step
		const newStep = {
github electricimp / Builder / src / FileCache.js View on Github external
_getCachedPath(link) {
    link = link.replace(/^github\:/, 'github#'); // replace ':' for '#' in github protocol
    link = link.replace(/\:\/\//, '#'); // replace '://' for '#' in url
    link = link.replace(/\//g, '-'); // replace '/' for '-'
    const parts = link.match(/^([^\?]*)(\?(.*))?$/); // delete get parameters from url
    if (parts && parts[3]) {
      link = parts[1] + XXHash.h64(parts[3], HASH_SEED);
    }
    if (link.length > MAX_FILENAME_LENGTH) {
      const startPart = link.substr(0, 100);
      const endPart = link.substr(link.length - 100);
      const middlePart = XXHash.h64(link, HASH_SEED);
      link = startPart + endPart + middlePart;
    }
    return path.join(this._cacheDir, link);
  }
github electricimp / Builder / src / FileCache.js View on Github external
_getCachedPath(link) {
    link = link.replace(/^github\:/, 'github#'); // replace ':' for '#' in github protocol
    link = link.replace(/\:\/\//, '#'); // replace '://' for '#' in url
    link = link.replace(/\//g, '-'); // replace '/' for '-'
    const parts = link.match(/^([^\?]*)(\?(.*))?$/); // delete get parameters from url
    if (parts && parts[3]) {
      link = parts[1] + XXHash.h64(parts[3], HASH_SEED);
    }
    if (link.length > MAX_FILENAME_LENGTH) {
      const startPart = link.substr(0, 100);
      const endPart = link.substr(link.length - 100);
      const middlePart = XXHash.h64(link, HASH_SEED);
      link = startPart + endPart + middlePart;
    }
    return path.join(this._cacheDir, link);
  }
github soheilpro / sqlmon / fields.js View on Github external
function queryHash(value) {
  if (value === null)
    return null;

  if (value.indexOf('exec sp_executesql') === 0) {
    value = value.replace(/,@\w+=.*/g, ''); // Remove everything after ',@Param1='
    value = value.replace(/varchar\(\d+\)/g, 'varchar()'); // Change 'varchar(xxx)' to 'varchar()'
  }

  value = value.replace(/[^0-9A-Za-z]+/g, ''); // Remove all non-alphanumeric characters

  return XXH.h64(value, 0xabcd).toString(36);
}
github wisnuc / appifi / test / individuals / iblt.js View on Github external
it('xxhashjs, xxhash, twice, expect 2847076442', function() {

    let js1 = XXH.h32("abcd", 0x01020304).toNumber()
    let js2 = XXH.h32("abcd", js1).toNumber()

    let buf = new Buffer("abcd")
    let ntv1 = xxhash.hash(buf, 0x01020304)
    let ntv2 = xxhash.hash(buf, ntv1)

    let enc = new Buffer(4)
    let enc2 = new Buffer(4)
    xxhash.hash(buf, 0x01020304, enc)

    expect(enc.equals(new Buffer('b5bfecd1', 'hex'))).to.be.true

    xxhash.hash(buf, enc.readUInt32LE(), enc)
    expect(enc.readUInt32LE()).to.equal(2847076642)
  })
})
github wisnuc / appifi / test / individuals / iblt.js View on Github external
it('xxhashjs, xxhash, twice, expect 2847076442', function() {

    let js1 = XXH.h32("abcd", 0x01020304).toNumber()
    let js2 = XXH.h32("abcd", js1).toNumber()

    let buf = new Buffer("abcd")
    let ntv1 = xxhash.hash(buf, 0x01020304)
    let ntv2 = xxhash.hash(buf, ntv1)

    let enc = new Buffer(4)
    let enc2 = new Buffer(4)
    xxhash.hash(buf, 0x01020304, enc)

    expect(enc.equals(new Buffer('b5bfecd1', 'hex'))).to.be.true

    xxhash.hash(buf, enc.readUInt32LE(), enc)
    expect(enc.readUInt32LE()).to.equal(2847076642)
  })
})
github LukeLin / js-stl / src / Search / BloomFilter.js View on Github external
remove(item){
        if(!Buffer.isBuffer(item)) item = Buffer.from(item);

        for(let i = 0; i < this.seeds.length; ++i){
            let hash = xxhash(item, this.seeds[i]).toString();
            let bit = hash % this.bits;

            this._unSetBit(bit);
        }
    }
}
github stricter / stricter / src / utils / index.ts View on Github external
export const getHashFunction = (): HashFunction => {
    const hasher = h32();
    hasher.init(123);

    return contents =>
        hasher
            .update(contents)
            .digest()
            .toString(16);
};
github DaanBroekhof / JoroDox / app / utils / tasks / DbBackgroundTask.js View on Github external
addRelationId(relationData) {
    relationData.id = XXHash.h64(
      [relationData.fromKey, relationData.fromType, relationData.fromId, relationData.toKey, relationData.toType, relationData.toId].join(','),
      42
    ).toString(16);

    return relationData;
  }

xxhashjs

xxHash in Javascript

MIT
Latest version published 6 years ago

Package Health Score

67 / 100
Full package analysis

Popular xxhashjs functions