it("should calc hash", () => { let strategy = new ShardStrategy(broker.registry, broker, {}); expect(strategy.getHash("John")).toBe(1631623841); expect(strategy.getHash("Jane")).toBe(731224371); expect(strategy.getHash("Adam")).toBe(2130539036); expect(strategy.getHash("John")).toBe(1631623841); expect(strategy.getHash("Jane")).toBe(731224371); expect(strategy.getHash("Adam")).toBe(2130539036); });
const hashNum = this.getHash(key.toString());
'page_compression': false, }, drupal_hash_salt: getHash(JSON.stringify(pantheonDatabases)), config_directory_name: 'config', settings: {
describe('getHash', () => { it('determines the SHA-1 hash of an existing file', () => { return images.getHash([knownShaPath]).then(hash => { expect(hash).to.equal(knownSha.substr(0, 12)) }) }) it('determines the SHA-1 hash of multiple files', () => { return images.getHash([knownShaPath, knownShaPath]).then(hash => { expect(hash).to.equal('cdb39cef22e6') }) }) it('returns null if the file does not exist', () => { return images.getHash([knownShaPath + 'notfound']).then(hash => { expect(hash).to.be.null() }) }) it('fails on file read errors', () => { return expect(images.getHash(process.cwd())).to.be.rejected() }) })
Promise.all([ images.getHash(monitorPaths), images.getBuiltImages() ]).then(([ hash, imgs ]) => { if (!hash) { throw new Error(`No "from" specified, and ${dockerfile} does not exist.`) } const [ image ] = imgs.filter(img => img.hash === hash) if (image) return images.getImageNameFromHash(hash) // Find the most recent binci build so we can delete it after the new one builds const mostRecent = imgs.reduce((acc, elem) => { if (acc.createdAt > elem.createdAt) return acc return elem }, {hash: null, createdAt: 0}) tags.push(images.getImageNameFromHash(hash)) return images.buildImage(dockerfile, tags) .then(imageName => { if (mostRecent.hash) { return images.deleteImage(images.getImageNameFromHash(mostRecent.hash)) .then(() => imageName) } return imageName }) })
parseHash({ param = '', url = '' }) { let urlDATA = ''; if (url !== '') { urlDATA = url; } const hash = urls.getHash({ url: urlDATA }); if (hash === '') { return null; } const pieces = hash.split('&'); const data = {}; let i; let parts; for (i = 0; i < pieces.length; i += 1) { parts = pieces[i].split('='); if (parts.length < 2) { parts.push(''); } data[decodeURIComponent(parts[0])] = decodeURIComponent(parts[1]); } if (param === '') { return data; } if (typeof data[param] === 'undefined') { return null; } return data[param]; }
name: filename, tempFilePath: getFilePath(), hash: getHash(), size, encoding,
location.href = url; } else { location.hash = getHash(url);
// Retrieve cache manifest of a file to cache, which contains the file/directory // contents hash and the `expires` date. const getManifestInfo = async function({ cachePath, move, ttl, digests }) { const manifestPath = getManifestPath(cachePath) const expires = getExpires(ttl) const hash = await getHash(digests, move) const manifest = { expires, hash } const manifestString = `${JSON.stringify(manifest, null, 2)}\n` const identical = await isIdentical({ hash, manifestPath, manifestString }) return { manifestInfo: { manifestPath, manifestString }, identical } }
it("should calc hash", () => { let strategy = new ShardStrategy(broker.registry, broker, { ringSize: 1000 }); expect(strategy.getHash("John")).toBe(841); expect(strategy.getHash("Jane")).toBe(371); expect(strategy.getHash("Adam")).toBe(36); expect(strategy.getHash("John")).toBe(841); expect(strategy.getHash("Jane")).toBe(371); expect(strategy.getHash("Adam")).toBe(36); });
const getEntryPath = ( selector: ViewModelResultSelector | string ): string => { if (typeof selector === 'string') { return `@@resolve/namedSelectors.${getHash(selector)}` } const { query: { name, aggregateIds, args }, } = selector return `${getHash(name)}.${getHash(aggregateIds)}.${getHash(args, 'no-args')}` }
// Retrieve cache manifest of a file to cache, which contains the file/directory // contents hash and the `expires` date. const getManifestInfo = async function({ cachePath, move, ttl, digests }) { const manifestPath = getManifestPath(cachePath) const expires = getExpires(ttl) const hash = await getHash(digests, move) const manifest = { expires, hash } const manifestString = `${JSON.stringify(manifest, null, 2)}\n` const identical = await isIdentical({ hash, manifestPath, manifestString }) return { manifestInfo: { manifestPath, manifestString }, identical } }
const getEntryPath = ( selector: ViewModelResultSelector | string ): string => { if (typeof selector === 'string') { return `@@resolve/namedSelectors.${getHash(selector)}` } const { query: { name, aggregateIds, args }, } = selector return `${getHash(name)}.${getHash(aggregateIds)}.${getHash(args, 'no-args')}` }