How to use murmurhash - 10 common examples

To help you get started, we’ve selected a few murmurhash 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 pubpub / pubpub / src / components / Markdown / Markdown.jsx View on Github external
return {children[0]};
		case 'htmlblock':
			const text = children[0];
			if (typeof text === 'string' || text instanceof String) {
				return {text};
			}
			break;
		case 'p':
			// if (children[0] === null){ return null; }
			// console.log('p arguments', arguments);
			props.className = 'p-block';
			props['data-hash'] = children[0] ? murmur.v2(children[0]) : 0;
			Component = 'div';
			break;
		case 'li':
			props['data-hash'] = children[0] ? murmur.v2(children[0]) : 0;
			break;
		case 'a':
			props['target'] = "_blank";
			break;
		case 'hr':
			return ;

		case 'references':
			return ;

		case 'footnotes':
			return ;

		case 'pubheader':
			// console.log(arguments);
			Component = 'div';
github optimizely / javascript-sdk / packages / optimizely-sdk / lib / core / bucketer / index.js View on Github external
_generateBucketValue: function(bucketingKey) {
    try {
      // NOTE: the mmh library already does cast the hash value as an unsigned 32bit int
      // https://github.com/perezd/node-murmurhash/blob/master/murmurhash.js#L115
      var hashValue = murmurhash.v3(bucketingKey, HASH_SEED);
      var ratio = hashValue / MAX_HASH_VALUE;
      return parseInt(ratio * MAX_TRAFFIC_VALUE, 10);
    } catch (ex) {
      throw new Error(sprintf(ERROR_MESSAGES.INVALID_BUCKETING_ID, MODULE_NAME, bucketingKey, ex.message));
    }
  },
};
github jovotech / jovo-framework / src / HappyMealGAnalyticsSender.ts View on Github external
sendSessionsPlayedCount(handleRequest: HandleRequest) {
        let jovo: Jovo = handleRequest.jovo!;

        let idHash = murmurhash.v3(jovo.$user.getId()!) + murmurhash.v3(jovo.getDeviceId()!);

        let visitor = this.initVisitor();


        if (jovo.getMappedIntentName() === 'StartGameIntent') {
            console.log("***************SEND Transaction");
            visitor!
                .transaction("0", (err) => {
                    console.log("callback from transaction...");
                     
                    err? console.log("error : "+ err!.message): console.log("no Error from transaction");
                })
                .item(1, 1, "GamesStarted", (err)  => {
                    console.log("callback from item...");
                    err? console.log("error: "+ err!.message) : console.log("no error for item");
                }).send();
github jovotech / jovo-framework / dist / src / GoogleAnalyticsSender.js View on Github external
getUserId(jovo) {
        if (!jovo) {
            this.throwJovoNotSetError();
        }
        //let idHash = murmurhash.v3(jovo.$user.getId()!) + murmurhash.v3(jovo.getDeviceId()!); //for local testing via different devices 
        const idHash = murmurhash.v3(jovo.$user.getId());
        const uuid = idHash.toString();
        return uuid;
    }
    /**
github nodefluent / node-sinek / lib / librdkafka / NProducer.js View on Github external
        this._murmur = (key, partitionCount) => murmur.v3(key) % partitionCount;
        break;
github snowplow / snowplow-javascript-tracker / src / js / lib / detectors.js View on Github external
var plugins = [];
		if (navigatorAlias.plugins)
		{
			for(var i = 0; i < navigatorAlias.plugins.length; i++)
			{
				if (navigatorAlias.plugins[i]) {
					var mt = [];
					for(var j = 0; j < navigatorAlias.plugins[i].length; j++) {
						mt.push([navigatorAlias.plugins[i][j].type, navigatorAlias.plugins[i][j].suffixes]);
					}
					plugins.push([navigatorAlias.plugins[i].name + "::" + navigatorAlias.plugins[i].description, mt.join("~")]);
				}
			}
		}
		return murmurhash3_32_gc(fingerprint.join("###") + "###" + plugins.sort().join(";"), hashSeed);
	};
github wix / stylable / packages / node / src / resolve-namespace.ts View on Github external
return (namespace: string, stylesheetPath: string) => {
        const configPath = findConfig('package.json', { cwd: dirname(stylesheetPath) });
        const config = require(configPath);
        const fromRoot = relative(dirname(configPath), stylesheetPath).replace(/\\/g, '/');
        return (
            prefix +
            namespace +
            hash.v3(hashSalt + config.name + '@' + config.version + '/' + fromRoot)
        );
    };
}
github nodefluent / node-sinek / lib / kafka / Publisher.js View on Github external
getPartitionForKey(key, partitionCount = 0) {

    if (typeof key !== "string") {
      return Promise.reject("key must be a valid string");
    }

    if (partitionCount === 0) {
      partitionCount = this.partitionCount;
    }

    return Promise.resolve(murmur(key) % partitionCount);
  }
github jitsucom / jitsu / configurator / frontend / src / lib / services / analytics.ts View on Github external
public getJitsuIdPayload({ email, uid}) {
    return {
      email: this._anonymizeUsers ? 'masked' : email,
      internal_id: this._anonymizeUsers ? 'hid_' + murmurhash.v3(email || uid) : uid
    };
  }
github jovotech / jovo-framework / jovo-integrations / jovo-analytics-googleanalytics / src / GoogleAnalytics.ts View on Github external
getUserId(jovo: Jovo): string {
    const idHash = murmurhash.v3(jovo.$user.getId()!);
    const uuid = idHash.toString();
    return uuid;
  }

murmurhash

A Node.js module for the optimized JavaScript implementation of the MurmurHash algorithms.

MIT
Latest version published 3 years ago

Package Health Score

65 / 100
Full package analysis

Popular murmurhash functions