How to use @sindresorhus/fnv1a - 4 common examples

To help you get started, we’ve selected a few @sindresorhus/fnv1a 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 drejohnson / sapper-graphql-firebase / src / svql / createClient.js View on Github external
function getCacheKey(operation) {
    const { key } = operation
    const cacheKey = fnv1a(
      '' + url + JSON.stringify(getFetchOptions(operation) + key),
    )
    return cacheKey
  }
github vadimdemedes / draqula / src / Draqula.ts View on Github external
private createQuery(query: DocumentNode): string {
		if (this.queryCache.has(query)) {
			return this.queryCache.get(query)!;
		}

		const queryString = print(addTypenames(query));
		this.queryCache.set(query, queryString);

		const queryId = String(hash(queryString));
		this.queryIds.set(query, queryId);
		this.dataCache.set(queryId, new Map());

		return queryString;
	}
github nearform / graphql-hooks / packages / graphql-hooks-memcache / src / index.js View on Github external
function generateKey(keyObj) {
  return fnv1a(JSON.stringify(keyObj)).toString(36)
}
github pencil-js / pencil.js / modules / text / text.js View on Github external
return (text, options) => {
        const key = hash(`${text}${JSON.stringify(options)}`);
        if (cache[key] !== undefined) {
            return cache[key];
        }

        sandbox.font = Text.getFontDefinition(options);
        const lines = formatString(text);
        const height = options.fontSize * options.lineHeight * lines.length;
        const width = lines.reduce((max, line) => Math.max(max, sandbox.measureText(line).width), 0);
        const result = {
            width,
            height,
        };
        cache[key] = result;
        return result;
    };
})();

@sindresorhus/fnv1a

FNV-1a non-cryptographic hash function

MIT
Latest version published 5 months ago

Package Health Score

70 / 100
Full package analysis

Popular @sindresorhus/fnv1a functions