From a0b9d167564e43ed5ee4b4d3de99af0924e67dc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Zl=C3=A1mal?= Date: Tue, 14 Jan 2025 11:11:13 +0100 Subject: [PATCH] Murmur: remove --- scripts/publishedPackages.json | 1 - src/murmur-hash/.npmignore | 1 - src/murmur-hash/CHANGELOG.md | 15 ---- src/murmur-hash/LICENSE | 22 ----- src/murmur-hash/README.md | 25 ------ src/murmur-hash/package.json | 19 ----- .../src/__tests__/murmurHash.test.js | 14 ---- src/murmur-hash/src/murmurHash.js | 82 ------------------- yarn.lock | 8 -- 9 files changed, 187 deletions(-) delete mode 100644 src/murmur-hash/.npmignore delete mode 100644 src/murmur-hash/CHANGELOG.md delete mode 100644 src/murmur-hash/LICENSE delete mode 100644 src/murmur-hash/README.md delete mode 100644 src/murmur-hash/package.json delete mode 100644 src/murmur-hash/src/__tests__/murmurHash.test.js delete mode 100644 src/murmur-hash/src/murmurHash.js diff --git a/scripts/publishedPackages.json b/scripts/publishedPackages.json index 374480585e..214382e1ea 100644 --- a/scripts/publishedPackages.json +++ b/scripts/publishedPackages.json @@ -8,7 +8,6 @@ "@adeira/monorepo-npm-publisher", "@adeira/monorepo-shipit", "@adeira/monorepo-utils", - "@adeira/murmur-hash", "@adeira/relay", "@adeira/shell-command", "eslint-plugin-adeira" diff --git a/src/murmur-hash/.npmignore b/src/murmur-hash/.npmignore deleted file mode 100644 index c912533dd7..0000000000 --- a/src/murmur-hash/.npmignore +++ /dev/null @@ -1 +0,0 @@ -__tests__ diff --git a/src/murmur-hash/CHANGELOG.md b/src/murmur-hash/CHANGELOG.md deleted file mode 100644 index 5f78ba82a9..0000000000 --- a/src/murmur-hash/CHANGELOG.md +++ /dev/null @@ -1,15 +0,0 @@ -# Unreleased - -# 2.0.1 - -- Dependencies update. - -Note for all Flow users: all projects in [`adeira/universe`](https://github.com/adeira/universe) now use implicit exact Flow types (`{}` for strict objects and `{ ... }` for open objects, syntax `{||}` is deprecated). We do not expect any issues as long as you are using `exact_by_default=true` Flow option. - -# 2.0.0 - -Support for Node.js 12 has been removed. This package might continue working on older Node.js versions, however, it's highly recommended upgrading to Node.js version 14 or newer. For more details, see: https://nodejs.org/en/about/releases/, or discuss here: https://github.com/adeira/universe/discussions/1588 - -# 1.0.0 - -Initial stable release. diff --git a/src/murmur-hash/LICENSE b/src/murmur-hash/LICENSE deleted file mode 100644 index efffa72a31..0000000000 --- a/src/murmur-hash/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -MIT License - -Copyright (c) 2019-present, Adeira -Copyright (c) 2013-present, Facebook, Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/src/murmur-hash/README.md b/src/murmur-hash/README.md deleted file mode 100644 index 0e52fca244..0000000000 --- a/src/murmur-hash/README.md +++ /dev/null @@ -1,25 +0,0 @@ -Modified [MurmurHash](https://en.wikipedia.org/wiki/MurmurHash) algorithm returning base62 of murmur hash. This code was originally taken from [Relay utils](https://github.com/facebook/relay/blob/4f5d549f5276067595838b48ab3f3925fee174f7/packages/relay-compiler/util/murmurHash.js). - -Read more about MurmurHash in this Stack Overflow question: [MurmurHash - what is it?](https://stackoverflow.com/q/11899616/12646420) - -# Install - -```text -yarn add @adeira/murmur-hash -``` - -Optionally, install TS types (Flow types are included by default): - -```text -yarn add --dev @types/adeira__murmur-hash -``` - -# Basic usage - -```js -import murmurHash from '@adeira/murmur-hash'; - -const data = { arg: { count: 20, start: 0, end: 5 } }; -const hash = murmurHash(JSON.stringify(data)); -console.log(hash); // 4gykY2 -``` diff --git a/src/murmur-hash/package.json b/src/murmur-hash/package.json deleted file mode 100644 index d049b7525e..0000000000 --- a/src/murmur-hash/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "@adeira/murmur-hash", - "description": "Non-cryptographic hash function suitable for general hash-based lookup.", - "homepage": "https://github.com/adeira/universe", - "bugs": "https://github.com/adeira/universe/issues", - "repository": { - "type": "git", - "url": "git@github.com:adeira/universe.git", - "directory": "src/murmur-hash" - }, - "license": "MIT", - "version": "2.0.1", - "main": "./src/murmurHash.js", - "type": "commonjs", - "sideEffects": false, - "dependencies": { - "@babel/runtime": "^7.26.0" - } -} diff --git a/src/murmur-hash/src/__tests__/murmurHash.test.js b/src/murmur-hash/src/__tests__/murmurHash.test.js deleted file mode 100644 index 4aadc9500e..0000000000 --- a/src/murmur-hash/src/__tests__/murmurHash.test.js +++ /dev/null @@ -1,14 +0,0 @@ -// @flow strict - -import murmurHash from '../murmurHash'; - -it.each` - input | output - ${'{count: 20, start: 0, end: 5}'} | ${'31sjku'} - ${'{arg: "{arg: {count: 20, start: 0, end: 5}}"}'} | ${'3RGiWM'} - ${'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.repeat(40)} | ${'3OKbT6'} - ${'{}'} | ${'2wIPj2'} - ${''} | ${'0'} -`('works as expected for output [$output]', ({ input, output }) => { - expect(murmurHash(input)).toEqual(output); -}); diff --git a/src/murmur-hash/src/murmurHash.js b/src/murmur-hash/src/murmurHash.js deleted file mode 100644 index 752fc5ebe4..0000000000 --- a/src/murmur-hash/src/murmurHash.js +++ /dev/null @@ -1,82 +0,0 @@ -// @flow strict - -/* eslint-disable no-bitwise */ - -/** - * Based on implementations by Gary Court and Austin Appleby, 2011, MIT. - * @preserve-header - */ - -const BASE62 = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; - -/** - * @param {string} str A UTF-16 or ASCII string - * @return {string} a base62 murmur hash - */ -export default function murmurHash(str: string): string { - const length = str.length; - const rem = length & 3; - const len = length ^ rem; - - let h = 0; - let i = 0; - let k; - - while (i !== len) { - const ch4 = str.charCodeAt(i + 3); - - k = - str.charCodeAt(i) ^ - (str.charCodeAt(i + 1) << 8) ^ - (str.charCodeAt(i + 2) << 16) ^ - ((ch4 & 0xff) << 24) ^ - ((ch4 & 0xff00) >> 8); - - i += 4; - - k = (k * 0x2d51 + (k & 0xffff) * 0xcc9e0000) >>> 0; - k = (k << 15) | (k >>> 17); - k = (k * 0x3593 + (k & 0xffff) * 0x1b870000) >>> 0; - h ^= k; - h = (h << 13) | (h >>> 19); - h = (h * 5 + 0xe6546b64) >>> 0; - } - - k = 0; - switch (rem) { - case 3: - k ^= str.charCodeAt(len + 2) << 16; - // falls through - case 2: - k ^= str.charCodeAt(len + 1) << 8; - // falls through - case 1: - k ^= str.charCodeAt(len); - - k = (k * 0x2d51 + (k & 0xffff) * 0xcc9e0000) >>> 0; - k = (k << 15) | (k >>> 17); - k = (k * 0x3593 + (k & 0xffff) * 0x1b870000) >>> 0; - h ^= k; - } - - h ^= length; - h ^= h >>> 16; - h = (h * 0xca6b + (h & 0xffff) * 0x85eb0000) >>> 0; - h ^= h >>> 13; - h = (h * 0xae35 + (h & 0xffff) * 0xc2b20000) >>> 0; - h ^= h >>> 16; - - h >>>= 0; - - if (!h) { - return '0'; - } - - let s = ''; - while (h) { - const d = h % 62; - s = BASE62[d] + s; - h = (h - d) / 62; - } - return s; -} diff --git a/yarn.lock b/yarn.lock index 3acb6cb738..246c3af65f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -184,14 +184,6 @@ __metadata: languageName: unknown linkType: soft -"@adeira/murmur-hash@workspace:src/murmur-hash": - version: 0.0.0-use.local - resolution: "@adeira/murmur-hash@workspace:src/murmur-hash" - dependencies: - "@babel/runtime": "npm:^7.26.0" - languageName: unknown - linkType: soft - "@adeira/relay@workspace:src/relay": version: 0.0.0-use.local resolution: "@adeira/relay@workspace:src/relay"