diff --git a/packages/imagetools_3/astroViteConfigs.js b/packages/imagetools_3/astroViteConfigs.js index 9ea2454..2f7b5cc 100644 --- a/packages/imagetools_3/astroViteConfigs.js +++ b/packages/imagetools_3/astroViteConfigs.js @@ -1,12 +1,12 @@ export default { - "environment": "dev", + "environment": "build", "isSsrBuild": false, "projectBase": "", - "publicDir": "C:\\Users\\zx\\Desktop\\polymech\\library.polymech\\public\\", - "rootDir": "C:\\Users\\zx\\Desktop\\polymech\\library.polymech\\", - "mode": "dev", - "outDir": "dist", - "assetsDir": "/_astro", - "sourcemap": "inline", + "publicDir": "C:\\Users\\zx\\Desktop\\polymech\\site2\\public\\", + "rootDir": "C:\\Users\\zx\\Desktop\\polymech\\site2\\", + "mode": "production", + "outDir": "C:\\Users\\zx\\Desktop\\polymech\\site2\\dist\\", + "assetsDir": "_astro", + "sourcemap": false, "assetFileNames": "/_astro/[name]@[width].[hash][extname]" } \ No newline at end of file diff --git a/packages/node-murmurhash-native/.gitignore b/packages/node-murmurhash-native/.gitignore deleted file mode 100644 index 079541c..0000000 --- a/packages/node-murmurhash-native/.gitignore +++ /dev/null @@ -1,20 +0,0 @@ -.DS_Store -Thumbs.db -.svn -*.tmp -*.log -*~ -*.lnk -*.sublime-project -*.sublime-workspace -sftp-config.json -/node_modules -/tmp -/build -*.o -*.so -.nyc_output -*.tgz -/lib -package-lock.json -/doc diff --git a/packages/node-murmurhash-native/.jshintrc b/packages/node-murmurhash-native/.jshintrc deleted file mode 100644 index 4490759..0000000 --- a/packages/node-murmurhash-native/.jshintrc +++ /dev/null @@ -1,6 +0,0 @@ -{ - "node": true, - "laxcomma": true, - "laxbreak": true, - "undef": true -} \ No newline at end of file diff --git a/packages/node-murmurhash-native/.npmignore b/packages/node-murmurhash-native/.npmignore deleted file mode 100644 index b0a80a8..0000000 --- a/packages/node-murmurhash-native/.npmignore +++ /dev/null @@ -1,27 +0,0 @@ -.jshintrc -.travis.yml -appveyor.yml -bench/ -test/ -checkout-murmurhash.sh - -# MIRRORED FROM .gitignore -.DS_Store -Thumbs.db -.svn -*.tmp -*.log -*~ -*.lnk -*.sublime-project -*.sublime-workspace -sftp-config.json -/node_modules -/tmp -/build -*.o -*.so -.nyc_output -*.tgz -/lib -/doc diff --git a/packages/node-murmurhash-native/.npmrc b/packages/node-murmurhash-native/.npmrc deleted file mode 100644 index 43c97e7..0000000 --- a/packages/node-murmurhash-native/.npmrc +++ /dev/null @@ -1 +0,0 @@ -package-lock=false diff --git a/packages/node-murmurhash-native/.travis.yml b/packages/node-murmurhash-native/.travis.yml deleted file mode 100644 index 3ae2035..0000000 --- a/packages/node-murmurhash-native/.travis.yml +++ /dev/null @@ -1,70 +0,0 @@ -sudo: false -language: node_js -env: - global: - secure: "LKh0Cc14itGFicEVCD+whTswTmI0HzWqy1C3cLw2z16TgST2dtmMdmUFXU1jNATfi0l4qqwrlnIgJrtzFNrc5fwxMY7XYr71F9QjfWIY7hfrTh3iZBYZJdlUdx0zClwGsN06ldDiaxKKljf/OmXuu5tds5iyel5O8KKZUaIFzKc=" - -os: - - windows - - osx - - linux - -node_js: [10, 11, 12, 13, 14] -addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - g++-4.9 - -osx_image: xcode8 - -matrix: - exclude: - # until travis.ci resolves problem with "VM fails to come up if you have secrets" - # https://travis-ci.community/t/current-known-issues-please-read-this-before-posting-a-new-topic/264 - - os: windows - -before_install: - - if [[ $TRAVIS_OS_NAME == "linux" ]]; then CXX=g++-4.9; fi - - if [[ $TRAVIS_OS_NAME == "osx" ]]; then CXX=g++; fi # g++ is an alias of clang, so let's use it - # update npm - - | - echo "TRAVIS_NODE_VERSION=$TRAVIS_NODE_VERSION" - if [[ $TRAVIS_NODE_VERSION -le 6 ]]; then NPM_VERSION=3 - elif [[ $TRAVIS_NODE_VERSION -le 8 ]]; then NPM_VERSION=4 - elif [[ $TRAVIS_NODE_VERSION -le 9 ]]; then NPM_VERSION=5 - else NPM_VERSION=6 - fi - echo "NPM_VERSION=$NPM_VERSION" - - npm -g install npm@${NPM_VERSION} - # print versions - - node --version - - npm --version - - if [[ $TRAVIS_OS_NAME != "windows" ]]; then $CXX --version; fi - # install windows-build-tools - - if [[ $TRAVIS_OS_NAME == "windows" ]]; then npm install --global --production windows-build-tools; fi - - if [[ $TRAVIS_OS_NAME == "windows" ]]; then setx PYTHON "%USERPROFILE%\.windows-build-tools\python27\python.exe"; fi - # figure out if we should publish - - PUBLISH_BINARY=no - # if we are building a tag then publish - - echo $TRAVIS_BRANCH - - echo `git describe --tags --always HEAD` - - if [[ $TRAVIS_BRANCH == `git describe --tags --always HEAD` ]]; then PUBLISH_BINARY=yes; fi; - - echo "Are we going to publish a binary? ->" $PUBLISH_BINARY - -install: - # ensure source install works - - npm install --build-from-source - # compile typescript tests - - npm run tsc - -script: - - npm test - # publish on a tag - - if [[ $PUBLISH_BINARY == yes ]]; then node-pre-gyp package; fi; - - if [[ $PUBLISH_BINARY == yes ]]; then node-pre-gyp-github publish --release; fi; - # cleanup - - node-pre-gyp clean - # test binary exists - - if [[ $PUBLISH_BINARY == yes ]]; then npm install --fallback-to-build=false; fi; diff --git a/packages/node-murmurhash-native/HISTORY.md b/packages/node-murmurhash-native/HISTORY.md deleted file mode 100644 index 0f4d230..0000000 --- a/packages/node-murmurhash-native/HISTORY.md +++ /dev/null @@ -1,168 +0,0 @@ -v3.5.0 -* bump nan to 2.14.1, node-pre-gyp to 0.14.0 -* bump development dependencies -* added binaries for node v13 and v14 -* dropped binaries for node pre v10 - -v3.4.1 -* restrict node to v6 or later - -v3.4.0 -* bump nan to 2.13 and remove v8 deprecation warnings suppression introduced in v3.2.5 -* bump node-pre-gyp to 0.13 and node-pre-gyp-github to 1.4.3 -* bump development dependencies -* bump typescript and typedoc dependencies -* added tests and binaries for node v12 -* dropped support for node pre v6 - -v3.3.0 - -* TypeScript declarations, documentation and tests -* bump bluebird to 3.5.3, commander to 2.19.0 and tap to 12.1.0 -* added development dependencies: typescript, @types, typedoc and typedoc plugins - -v3.2.5 - -* bump node-pre-gyp to 0.11.0, nan to 2.11.1 and tap to 12.0.1 -* adapt async uncaughtException tests to tap 12 -* test and release binaries for node v11 -* suppress v8 deprecation warnings from nan - -v3.2.4 - -* bump node-pre-gyp to 0.10.3, commander to 2.17 -* test and release binaries for nodejs v10 -* replaced deprecated Buffer factory api in tests and benches with the class methods - -v3.2.3 - -* bump nan to 2.10, node-pre-gyp to 0.9.1, tap to 9, commander to 2.15 -* replaced deprecated synchronous Nan::Callback::Call with Nan::Call -* removed redundant const Nan::NAN_METHOD_ARGS_TYPE -* updated arguments to asynchronous Nan::Callback::Call -* dropped support for node pre v4 (broken node-gyp 0.12.18 on XCode LLVM 8.1) - on other systems it might still work though - not looking into it anymore - -v3.2.2 - -* bump nan to 2.7.0, node-pre-gyp to 0.6.39 -* bump development dependencies -* replace deprecated Nan::ForceSet with Nan::DefineOwnProperty -* test and release binaries for node v8 and v9 -* appveyor: pin npm version 5.3 for node v9 to workaround npm's issue #16649 -* npmrc: turn off package-lock - -v3.2.1 - -* bump nan to 2.6.2, node-pre-gyp to 0.6.34 -* bump development dependencies -* test and release binaries for node v7 -* appveyor: pin npm versions - -v3.2.0 - -* bump nan to 2.3.5 -* removed strcasecmp dependency -* asynchronous: static byte array for small strings added to the worker -* incremental async: static byte array for small strings added to the hasher -* incremental: endianness configurable via property and argument to the constructor -* variants of murmur hash functions producing BE (MSB) or LE (LSB) results - -v3.1.1 - -* fix incremental async: ensure hasher is not GC'ed before worker completes -* fix incremental async: prevent from copying state over busy target - -v3.1.0 - -* replaced MurmurHash3 implementation with PMurHash and PMurHash128 -* new ability to update incremental hashers asynchronously via libuv -* stream implementation chooses sync vs async update depending on chunk size -* test: ensure persistence under gc stress -* bench: streaming - -v3.0.4 - -* test cases: incremental digest() method with buffer output -* fix stream.js wrapper: missing support for offset and length in digest() - -v3.0.3 - -* improved node-pre-gyp configuration so only essential binaries are being packaged - -v3.0.2 - -* removed bundled dependencies - -v3.0.1 - -* facilitate installation with prebuilt native binaries -* use "bindings" gem for finding native modules -* backward compatibility testing of serialized data -* c++ code cleanup: most of the precompiler macros replaces with type-safe constants -* js code cleanup with jshint -* remove iojs-3 from ci tests - -v3.0.0 - -* results always in network order MSB (byte) -* restored output types: "hex" "base64" and "binary" -* incremental MurmurHash 3: 32bit, 128bit x86 and x64 -* copyable and serializable state of incremental MurmurHash -* stream wrapper for incremental MurmurHash - -v2.1.0 - -* new ability to calculate hashes asynchronously via libuv -* ensure correct byte alignment while directly writing to a buffer -* bench: asynchronous version -* promisify wrapper - -v2.0.0 - -* output string encoding types removed -* "number" output type is a hex number for 64 and 128bit hashes -* "number" output type is the default output type for all hashes -* consistent hash regardless of platform endian-ness -* throws TypeError on incorrect encoding or output_type -* second string argument interpreted as an output type or encoding -* remove legacy pre v0.10 code - -v1.0.2 - -* bump nan to 2.3.3, fixes node v6 buld - -v1.0.1 - -* use nan converters instead of soon deprecated ->XValue() - -v1.0.0 - -* bump nan to 2.0.9, fixes build with iojs-3 and node v4 - -v0.3.1 - -* bump nan to 1.8, fixes build with newset io.js - -v0.3.0 - -* output Buffer, offset and length arguments -* use NODE_SET_METHOD macro to export functions - -v0.2.1 - -* bump nan to 1.6, remove polyfill -* bench: compare with all crypto hashes - -v0.2.0 - -* default input encoding changed from "utf8" to "binary" -* ensure default output type is "number" (32bit) or "buffer" (>32bit) -* decode "utf8" string faster on node >= 0.10 -* handle some cases of 3 arguments better -* bench: compare with md5/sha1 -* bench: string encoding argument - -v0.1.1 - -* fix handling of non-ascii encoding argument string diff --git a/packages/node-murmurhash-native/LICENSE b/packages/node-murmurhash-native/LICENSE deleted file mode 100644 index 5953fa8..0000000 --- a/packages/node-murmurhash-native/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2015 royal at yeondir.com - -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/packages/node-murmurhash-native/README.md b/packages/node-murmurhash-native/README.md deleted file mode 100644 index 81b8ac9..0000000 --- a/packages/node-murmurhash-native/README.md +++ /dev/null @@ -1,329 +0,0 @@ -MurmurHash bindings for node -============================ - -This library provides Austin Appleby's non-cryptographic "MurmurHash" hashing algorithm functions in a few different flavours. - -[![NPM][NPM img]][NPM Status] -[![Node][Node img]][NPM Status] -[![Travis][Travis img]][Travis Status] -[![AppVeyor][AppVeyor img]][AppVeyor Status] -[![License][License img]][License Link] - -Key features: - -* blocking and asynchronous api interfaces -* additional MurmurHash3 32 and 128 bit progressive implementations based on [PMurHash][PMurHash] -* stream wrapper for progressive hasher with [crypto.Hash-like][crypto.Hash] bi-api interface -* serializable state of the progressive hasher -* BE or LE byte order variants of hashes -* promise wrapper -* prebuilt binaries for most standard system configurations -* TypeScript declarations ([docs][typescript-docs]) - -Install: --------- - -There are prebuilt [binaries][releases] available for painless installation on -some Linuxes (x64), OS-X (x64) and Windows (x64 and x86) thanks to [node-pre-gyp][node-pre-gyp] and [node-pre-gyp-github][node-pre-gyp-github]. - -``` -npm install murmurhash-native -``` - -If the prebuilt release is not available for your system or nodejs version, -the compilation from source will kick-in. For more information on building from -source please consult [this page][node-gyp-install]. - -If for some reason (e.g. an incompatible GLIBC) you might want to force building from source, type: - -``` -npm i murmurhash-native --build-from-source -``` - -To reinstall prebuilt binary (e.g. after switching between major nodejs versions): - -``` -npm rebuild --update-binary -``` - -TypeScript ----------- - -`murmurhash-native` is [ready][typescript-docs] for the TypeScript without any external declarations. However this module is node-specific package, if you're going to use it in TypeScript, do not forget to include `@types/node` and enable `es2015` language features in your `tsconfig.json`. - -Make a hash: ------------- - -```js -var murmurHash = require('murmurhash-native').murmurHash - -murmurHash( 'hash me!' ) // 2061152078 -murmurHash( new Buffer('hash me!') ) // 2061152078 -murmurHash( 'hash me!', 0x12345789 ) // 1908692277 -murmurHash( 'hash me!', 0x12345789, 'buffer' ) // -murmurHash( 'hash me!', 0x12345789, 'hex' ) // '71c45535' -var buf = new Buffer('hash me!____') -murmurHash( buf.slice(0,8), 0x12345789, buf, 8 ) -// - -var murmurHash128x64 = require('murmurhash-native').murmurHash128x64 -murmurHash128x64( 'hash me!' ) // 'c43668294e89db0ba5772846e5804467' - -var murmurHash128x86 = require('murmurhash-native').murmurHash128x86 -murmurHash128x86( 'hash me!' ) // 'c7009299985a5627a9280372a9280372' - -// asynchronous - -murmurHash( 'hash me!', function(err, hash) { assert.equal(hash, 2061152078) }); - -// output byte order (default is BE) - -var murmurHashLE = require('murmurhash-native').LE.murmurHash; -murmurHashLE( 'hash me!', 0x12345789, 'buffer' ) // -murmurHashLE( 'hash me!', 0x12345789, 'hex' ) // '3555c471' -``` - -These functions are awaiting your command: - -* `murmurHash` - MurmurHash v3 32bit -* `murmurHash32` - (an alias of murmurHash) -* `murmurHash128` - MurmurHash v3 128bit platform (x64 or x86) optimized -* `murmurHash128x64` - MurmurHash v3 128bit x64 optimized -* `murmurHash128x86` - MurmurHash v3 128bit x86 optimized -* `murmurHash64` - MurmurHash v2 64bit platform (x64 or x86) optimized -* `murmurHash64x64` - MurmurHash v2 64bit x64 optimized -* `murmurHash64x86` - MurmurHash v2 64bit x86 optimized - -and they share the following signature: - -```js -murmurHash(data[, callback]) -murmurHash(data, output[, offset[, length]][, callback]) -murmurHash(data{string}, encoding|output_type[, seed][, callback]) -murmurHash(data{Buffer}, output_type[, seed][, callback]) -murmurHash(data, seed[, callback]) -murmurHash(data, seed, output[, offset[, length]][, callback]) -murmurHash(data, seed, output_type[, callback]) -murmurHash(data, encoding, output_type[, callback]) -murmurHash(data{string}, encoding, output[, offset[, length]][, callback]) -murmurHash(data{string}, encoding, seed[, callback]) -murmurHash(data{string}, encoding, seed, output[, offset[, length]][, callback]) -murmurHash(data{string}, encoding, seed, output_type[, callback]) -``` - -* `@param` `{string|Buffer}` `data` - a byte-string to calculate hash from -* `@param` `{string}` `encoding` - data string encoding, should be: - "utf8", "ucs2", "ascii", "hex", "base64" or "binary"; - "binary" by default -* `@param` `{Uint32}` `seed` - murmur hash seed, 0 by default -* `@param` `{Buffer}` `output` - a Buffer object to write hash bytes to; - the same object will be returned -* `@param` `{number}` `offset` - start writing into output at offset byte; - negative offset starts from the end of the output buffer -* `@param` `{number}` `length` - a number of bytes to write from calculated hash; - negative length starts from the end of the hash; - if absolute value of length is larger than the size of calculated - hash, bytes are written only up to the hash size -* `@param` `{string}` `output_type` - a string indicating return type: - - "number" - (default) for murmurHash32 an unsigned 32-bit integer, - other hashes - hexadecimal string - - "hex" - hexadecimal string - - "base64" - base64 string - - "binary" - binary string - - "buffer" - a new Buffer object; -* `@param` `{string}` `encoding|output_type` - data string encoding - or a return type; because some valid return types are also valid - encodings, the only values recognized here for `output_type` are: - - "number" - - "buffer" -* `@param` `{Function}` `callback` - optional callback(err, result) - if provided the hash will be calculated asynchronously using libuv - worker queue, the return value in this instance will be `undefined` - and the result will be provided to the callback function; - Be carefull as reading and writing by multiple threads to the same - memory may render undetermined results - -* `@return` `{number|Buffer|String|undefined}` - -The order of bytes written to a Buffer or encoded string depends on -function's endianness. - -`data` and `output` arguments might reference the same Buffer object -or buffers referencing the same memory (views). - - -There are additional namespaces, each for different variant of function endianness: - -* `BE` - big-endian (most significant byte first or network byte order) -* `LE` - little-endian (least significant byte first) -* `platform` - compatible with `os.endianness()` - -Functions in the root namespace are big-endian. - - -Streaming and incremental api ------------------------------ - -The dual-api interface for progressive MurmurHash3 is available as a submodule: - -```js -var murmur = require('murmurhash-native/stream'); -```` - -Incremental (a.k.a. progressive) api - -```js -var hash = murmur.createHash('murmurhash128x86'); -hash.update('hash').digest('hex'); // '0d872bbf2cd001722cd001722cd00172' -hash.update(' me!').digest('hex'); // 'c7009299985a5627a9280372a9280372' - -var hash = murmur.createHash('murmurhash128x86', {endianness: 'LE'}); -hash.update('hash').digest('hex'); // 'bf2b870d7201d02c7201d02c7201d02c' -hash.update(' me!').digest('hex'); // '999200c727565a98720328a9720328a9' -``` - -Streaming api - -```js -var hash = murmur.createHash('murmurhash32', {seed: 123, encoding: 'hex', endianness: 'platform'}); -fs.createReadStream('README.md').pipe(hash).pipe(process.stdout); -``` - -### Serializable state - -The incremental MurmurHash utilities may be serialized and later deserialized. -One may also copy a hasher's internal state onto another. -This way the hasher utility can be re-used to calculate a hash of some data -with already known prefix. - -```js -var hash = murmur.createHash('murmurhash128x64').update('hash'); -hash.digest('hex'); // '4ab2e1e022f63e2e9add75dfcea2dede' - -var backup = murmur.createHash(hash); // create a copy of a hash with the same internal state -backup.update(' me!').digest('hex'); // 'c43668294e89db0ba5772846e5804467' - -hash.copy(backup) // copy hash's state onto the backup - .update(' me!').digest('hex'); // 'c43668294e89db0ba5772846e5804467' - -var serial = hash.serialize(); // serialize hash's state -serial == 'AAAAAAAAAAAAAAAAAAAAAGhzYWgAAAAAAAAAAAAAAFQAAAAEtd3X'; - // restore backup from serialized state -var backup = murmur.createHash('murmurhash128x64', {seed: serial}); -backup.update(' me!').digest('hex'); // 'c43668294e89db0ba5772846e5804467' - // finally -hash.update(' me!').digest('hex'); // 'c43668294e89db0ba5772846e5804467' -``` - -The dual-api with streaming is a javascript wrapper over the native module. -The native incremental module is directly available at `murmurhash-native/incremental`. - -See [hasher.cc](src/incremental/hasher.cc) for full api description -(and there's some crazy templating going on there...). - - -Promises --------- - -The native murmurHash functions run asynchronously if the last argument is a callback. -There is however a promisify wrapper: - -```js -var mm = require('murmurhash-native/promisify')(); -mm.murmurHash32Async( 'hash me!', 0x12345789 ) - .then(hash => { assert.equal(hash, 1908692277) }); -// Promise { } -``` - -You may provide your own promise constructor: - -```js -var bluebird = require('bluebird'); -var mm = require('murmurhash-native/promisify')(bluebird); -mm.murmurHash32Async( 'hash me!', 0x12345789 ) - .then(hash => { assert.equal(hash, 1908692277) }); -// Promise { -// _bitField: 0, -// _fulfillmentHandler0: undefined, -// _rejectionHandler0: undefined, -// _promise0: undefined, -// _receiver0: undefined } -``` - - -Significant changes in 3.x --------------------------- - -The most important change is full platform indifference of rendered output. -In 2.x output hash as binary data provided via buffer was endian sensitive. -Starting with 3.x the data written to output buffer is always MSB (byte) first. - -The "hex", "base64" and "binary" output types has been (re)added, but this time -with a sane definition. - -So in this version the following is true on all platforms: - -```js -assert.strictEqual(murmurHash('foo', 'buffer').toString('hex'), murmurHash('foo', 0, 'hex')); -assert.strictEqual(murmurHash('foo', 'buffer').toString('base64'), murmurHash('foo', 0, 'base64')); -``` - - -Significant changes in 2.x --------------------------- - -The 1.x output types were very confusing. E.g. "hex" was just an equivalent of -`murmurHash(data, "buffer").toString("hex")` which rendered incorrect hexadecimal -number. So all the string output type encodings: "utf8", "ucs2", "ascii", "hex", -"base64" and "binary" were completely removed in 2.0 as being simply useless. - -The "number" output type has been adapted to all variants in a way more compatible -with other murmurhash [implementations][murmurhash3js]. For 32bit hash the return -value is an unsigned 32-bit integer (it was signed integer in 1.x) and for other -hashes it's a hexadecimal number. - -The "buffer" output type wasn't modified except that the default output is now -"number" for all of the hashes. - -Additionally when passing unsupported value to `encoding` or `output_type` -argument the function throws `TypeError`. - -Another breaking change is for the BE platforms. Starting with 2.0 endian-ness -is recognized, so hashes should be consistent regardless of the cpu type. - -Since v2.1 the callback argument was introduced. - - -Bugs, limitations, caveats --------------------------- -When working with Buffers, input data is not being copied, however for strings -this is unavoidable. For strings with byte-length < 1kB the static buffer is -provided to avoid mem-allocs. - -The hash functions optimized for x64 and x86 produce different results. - -Tested on Linux (x64), OS X (x64) and MS Windows (x64 and x86). - -This version provides binaries for nodejs: v10, v11, v12, v13 and v14. - -For binaries of murmurhash-native for previous versions of nodejs, use version -3.4.1 or 3.3.0 of this module. - -[Travis Status]: https://travis-ci.org/royaltm/node-murmurhash-native -[Travis img]: https://img.shields.io/travis/royaltm/node-murmurhash-native.svg?maxAge=86400&style=flat-square&label=unix -[AppVeyor img]: https://img.shields.io/appveyor/ci/royaltm/node-murmurhash-native.svg?maxAge=86400&style=flat-square&label=windows -[AppVeyor Status]: https://ci.appveyor.com/project/royaltm/node-murmurhash-native -[NPM img]: https://img.shields.io/npm/v/murmurhash-native.svg?maxAge=86400&style=flat-square -[NPM Status]: https://www.npmjs.com/package/murmurhash-native -[Node img]: https://img.shields.io/node/v/murmurhash-native.svg?maxAge=2592000&style=flat-square -[License img]: https://img.shields.io/npm/l/murmurhash-native.svg?maxAge=2592000&style=flat-square -[License Link]: https://opensource.org/licenses/MIT -[bitHound img]: https://img.shields.io/bithound/dependencies/github/royaltm/node-murmurhash-native.svg?maxAge=86400&style=flat-square -[murmurhash3js]: https://www.npmjs.com/package/murmurhash3js -[PMurHash]: https://github.com/aappleby/smhasher/blob/master/src/PMurHash.c -[crypto.Hash]: https://nodejs.org/dist/latest-v6.x/docs/api/crypto.html#crypto_class_hash -[node-pre-gyp]: https://github.com/mapbox/node-pre-gyp -[node-pre-gyp-github]: https://github.com/bchr02/node-pre-gyp-github -[releases]: https://github.com/royaltm/node-murmurhash-native/releases -[node-gyp-install]: https://github.com/nodejs/node-gyp#installation -[typescript-docs]: http://royaltm.github.io/node-murmurhash-native/globals.html \ No newline at end of file diff --git a/packages/node-murmurhash-native/appveyor.yml b/packages/node-murmurhash-native/appveyor.yml deleted file mode 100644 index 1ef5273..0000000 --- a/packages/node-murmurhash-native/appveyor.yml +++ /dev/null @@ -1,79 +0,0 @@ -# http://www.appveyor.com/docs/appveyor-yml -platform: -- x86 -- x64 - -configuration: -- Release - -environment: - NODE_PRE_GYP_GITHUB_TOKEN: - secure: zPYtraT93rgt16J0Egnm0+SD3u8ncUEjAbsquMN5zsY9qowJP/t362GfmtIgbJS4 - - matrix: - - {"nodejs_version": "10", "npm_version": "6"} - - {"nodejs_version": "11", "npm_version": "6"} - - {"nodejs_version": "12", "npm_version": "6"} - - {"nodejs_version": "13", "npm_version": "6"} - - {"nodejs_version": "14", "npm_version": "6"} - -# for: -# - -# matrix: -# exclude: -# - {"platform": "x64", "nodejs_version": "8", "npm_version": "4"} -# - {"platform": "x64", "nodejs_version": "9", "npm_version": "5"} -# - {"platform": "x64", "nodejs_version": "10", "npm_version": "6"} -# - {"platform": "x64", "nodejs_version": "11", "npm_version": "6"} - -matrix: - fast_finish: true - -install: -# https://www.appveyor.com/docs/lang/nodejs-iojs/#installing-any-version-of-nodejs-or-iojs -- ps: Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version) $env:platform -# - ps: Install-Product node $env:nodejs_version $env:platform; -- npm -g install npm@%NPM_VERSION% -- ps: $env:Path += ";$(pwd)\node_modules\.bin;$env:AppData\npm"; -- ps: > - @{ - "nodejs_version" = $env:nodejs_version - "platform" = $env:platform - "node binary version" = $(node -v) - "npm version" = $(npm -v) - "APPVEYOR_REPO_COMMIT_MESSAGE" = $env:APPVEYOR_REPO_COMMIT_MESSAGE - "git latest tag" = "$(git describe --tags --always HEAD)" - "appveyor_repo_tag" = $env:appveyor_repo_tag - } | Out-String | Write-Host; - -# Check if we're building the latest tag, if so -# then we publish the binaries if tests pass. -- ps: > - if ($env:appveyor_repo_tag -match "true" -and ("$(git describe --tags --always HEAD)" -eq $env:appveyor_repo_tag_name)) { - $env:publish_binary = 1; - } else { - $env:publish_binary = 0; - } - true; -- ps: > - if ($env:publish_binary -eq 1) { - "We're going to publish a binary!" | Write-Host - } else { - "We're NOT going to publish a binary" | Write-Host - } - true; - -build_script: -- npm install --build-from-source -- npm run tsc - -test_script: -- npm test -- IF %PUBLISH_BINARY% == 1 (node-pre-gyp package 2>&1) -- IF %PUBLISH_BINARY% == 1 (node-pre-gyp-github publish --release 2>&1) -- IF %PUBLISH_BINARY% == 1 (node-pre-gyp clean install) - -# Set build version format here instead of in the admin panel. -version: "{build}" - -deploy: off diff --git a/packages/node-murmurhash-native/bench/bench.all.sh b/packages/node-murmurhash-native/bench/bench.all.sh deleted file mode 100644 index 9ccb346..0000000 --- a/packages/node-murmurhash-native/bench/bench.all.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/sh - -SCRIPT=$(readlink -f "$0") -SCRIPTPATH=$(dirname "$SCRIPT") - -for bench in "$SCRIPTPATH"/bench*.js -do - echo $(basename "$bench") "$@" - node "$bench" "$@" || exit $? -done diff --git a/packages/node-murmurhash-native/bench/bench.async.js b/packages/node-murmurhash-native/bench/bench.async.js deleted file mode 100644 index b2d6da8..0000000 --- a/packages/node-murmurhash-native/bench/bench.async.js +++ /dev/null @@ -1,119 +0,0 @@ -#!/usr/bin/env node -"use strict"; - -var os = require('os') -, assert = require('assert') -, parben = require('./parben').parallel -, hash = require('..') -, incr = require('../incremental') -, duration = 1000 -, parallel = os.cpus().length -, stringEncoding = 'binary' -, outputType = 'number'; - -var program = require('commander'); - -program - .version(require(__dirname + '/../package.json').version) - .usage('[options] [seconds=1]') - .option('-n, --no-crypto', 'do not benchmark crypto hashers') - .option('-p, --parallel ', 'number of parallel threads', parseInt) - .option('-s, --small ', 'small string size in chars', 80) - .option('-l, --large ', 'large string/buffer size in kilos', 128) - .option('-o, --output [type]', 'output type') - .option('-e, --encoding [enc]', 'input string encoding') - .parse(process.argv); - -if (program.args.length > 0) duration = 1000*program.args[0]>>>0; - -if (program.encoding) { - stringEncoding = program.encoding; - console.log('string encoding: %s', stringEncoding); -} - -if (program.output) { - outputType = program.output; - console.log('output type: %s', outputType); -} - -if (program.parallel) { - parallel = Math.max(0, program.parallel>>>0); -} - -console.log('parallel threads: %d', parallel); -console.log('test duration: %d ms', duration); - -function incremental(constr) { - return function(data, encoding, outputType, next) { - var hash = new constr(); - return hash.update(data, encoding, function(err) { - next(err, hash.digest(outputType)); - }); - }; -} - -var funmatrix = [ - [hash.murmurHash, 'murmurHash '], - [hash.murmurHash64x86, 'murmurHash64x86 '], - [hash.murmurHash64x64, 'murmurHash64x64 '], - [hash.murmurHash128x86, 'murmurHash128x86 '], - [hash.murmurHash128x64, 'murmurHash128x64 '], - [incremental(incr.MurmurHash), 'MurmurHash '], - [incremental(incr.MurmurHash128x86), 'MurmurHash128x86 '], - [incremental(incr.MurmurHash128x64), 'MurmurHash128x64 '] -]; - -var queued = []; - -function fillrandom(buffer) { - for(var i = 0; i < buffer.length; ++i) - buffer[i] = (Math.random()*0x100)|0; - return buffer; -} - -function randomstring(length) { - var buffer = fillrandom(Buffer.allocUnsafe(length)); - return buffer.toString('binary'); -} - -function bench(size, inputStr, duration) { - var input = inputStr - ? randomstring(size) - : fillrandom(Buffer.allocUnsafe(size)); - funmatrix.forEach(function(args) { - var fun = args[0], name = args[1]; - queue(measure, inputStr ? "string" : "buffer", fun, name, duration, parallel, size, input); - }); -} - -bench(+program.small, true, duration); -bench(program.large*1024, true, duration); -bench(program.large*1024, false, duration); - -next(); - -function measure(label, fun, name, duration, parallel, size, arg) { - var cb = function(next) { fun(arg, stringEncoding, outputType, next); }; - parben.calibrate(duration, parallel, cb) - .then(function(iters) { - return parben(iters, parallel, cb); - }) - .then(function(res) { - fun(arg, stringEncoding, outputType, function(err, digest) { - assert.ifError(err); - console.log(name + "(" + label + "[" + size + "]): single: %s avg: %s %s", - (size / res.single / 1000).toFixed(4) + 'MB/s', - (size / res.avg / 1000).toFixed(4) + 'MB/s', - digest); - next(); - }); - }); -} - -function queue() { - queued.push([].slice.call(arguments, 0)); -} - -function next() { - if (queued.length > 0) setImmediate.apply(null, queued.shift()); -} diff --git a/packages/node-murmurhash-native/bench/bench.incremental.js b/packages/node-murmurhash-native/bench/bench.incremental.js deleted file mode 100644 index ba236db..0000000 --- a/packages/node-murmurhash-native/bench/bench.incremental.js +++ /dev/null @@ -1,99 +0,0 @@ -#!/usr/bin/env node -"use strict"; - -var crypto = require('crypto') -, ben = require('./parben') -, incr = require('../incremental') -, duration = 1000 -, stringEncoding = 'binary' -, outputType = 'hex'; - -var program = require('commander'); - -program - .version(require(__dirname + '/../package.json').version) - .usage('[options] [seconds=1]') - .option('-n, --no-crypto', 'do not benchmark crypto hashers') - .option('-l, --large ', 'large string/buffer size in kilos', 128) - .option('-o, --output [type]', 'output type') - .option('-e, --encoding [enc]', 'string encoding') - .parse(process.argv); - -if (program.args.length > 0) duration = 1000*program.args[0]>>>0; - -if (program.encoding) { - stringEncoding = program.encoding; - console.log('string encoding: %s', stringEncoding); -} - -if (program.output) { - outputType = program.output; - console.log('output type: %s', outputType); -} - -console.log('test duration: %d ms', duration); - -var funmatrix = [ - [incr.MurmurHash, 'MurmurHash '], - [incr.MurmurHash128x86, 'MurmurHash128x86 '], - [incr.MurmurHash128x64, 'MurmurHash128x64 '], -]; - -if (program.crypto) { - crypto.getHashes().forEach(function(cipher) { - var pad = ' '; - funmatrix.push([ - function() { return new crypto.createHash(cipher); }, - cipher + pad.substr(0, pad.length - cipher.length) - ]); - }); -} - -function fillrandom(buffer) { - for(var i = 0; i < buffer.length; ++i) - buffer[i] = (Math.random()*0x100)|0; - return buffer; -} - -function randomstring(length) { - var buffer = fillrandom(Buffer.allocUnsafe(length)); - return buffer.toString('binary'); -} - -function bench(size, inputStr, duration) { - var input = inputStr - ? randomstring(size) - : fillrandom(Buffer.allocUnsafe(size)); - funmatrix.forEach(function(args) { - var Hash = args[0], name = args[1]; - [1, 3, 4, 8, 16, 17, 32, 64, 101, 128, 1009, 1024, size / 4>>>0, size / 2>>>0].forEach(function(chunksize) { - measure(inputStr ? "string" : "buffer", chunksize, - function fun(stringEncoding, outputType) { - var hash = new Hash(); - for(var i = 0; i < size; i += chunksize) { - hash.update(input.slice(i, i + chunksize),stringEncoding); - } - return hash.digest(outputType); - }, name, duration, size, input); - }); - measure(inputStr ? "string" : "buffer", size, function fun(stringEncoding, outputType) { - return new Hash().update(input, stringEncoding).digest(outputType); - }, name, duration, size, input); - }); -} - -bench(program.large*1024, true, duration); -bench(program.large*1024, false, duration); - -function measure(label, chunk, fun, name, duration, size) { - var padstr = ' '; - var pad = function(str,pad) { return padstr.substr(0, (pad || padstr.length) - (''+str).length) + str; }; - - var cb = function(){ fun(stringEncoding, outputType); }; - var iters = ben.calibrate(duration, cb); - var ms = ben(iters, cb); - console.log(name + label + " (%s of %s): %s %s", - pad(chunk, size.toString().length), size, - pad((size / ms / 1000).toFixed(1) + 'MB/s'), - fun(stringEncoding, outputType)); -} diff --git a/packages/node-murmurhash-native/bench/bench.js b/packages/node-murmurhash-native/bench/bench.js deleted file mode 100644 index 9fdee58..0000000 --- a/packages/node-murmurhash-native/bench/bench.js +++ /dev/null @@ -1,103 +0,0 @@ -#!/usr/bin/env node -"use strict"; - -var crypto = require('crypto') -, ben = require('./parben') -, hash = require('..') -, incr = require('../incremental') -, createHash = crypto.createHash -, duration = 1000 -, stringEncoding = 'binary' -, outputType = 'number'; - -var program = require('commander'); - -program - .version(require(__dirname + '/../package.json').version) - .usage('[options] [seconds=1]') - .option('-n, --no-crypto', 'do not benchmark crypto hashers') - .option('-s, --small ', 'small string size in chars', 80) - .option('-l, --large ', 'large string/buffer size in kilos', 128) - .option('-o, --output [type]', 'output type') - .option('-e, --encoding [enc]', 'input string encoding') - .parse(process.argv); - -if (program.args.length > 0) duration = 1000*program.args[0]>>>0; - -if (program.encoding) { - stringEncoding = program.encoding; - console.log('string encoding: %s', stringEncoding); -} - -if (program.output) { - outputType = program.output; - console.log('output type: %s', outputType); -} -console.log('test duration: %d ms', duration); - -function cryptohasher(name, data, encoding) { - var sum = createHash(name); - sum.update(data, encoding); - return sum.digest('hex'); -} - -function incremental(constr) { - return function(data, encoding, outputType) { - return new constr().update(data, encoding).digest(outputType); - }; -} - -var funmatrix = [ - [hash.murmurHash, 'murmurHash '], - [hash.murmurHash64x86, 'murmurHash64x86 '], - [hash.murmurHash64x64, 'murmurHash64x64 '], - [hash.murmurHash128x86, 'murmurHash128x86 '], - [hash.murmurHash128x64, 'murmurHash128x64 '], - [incremental(incr.MurmurHash), 'MurmurHash '], - [incremental(incr.MurmurHash128x86), 'MurmurHash128x86 '], - [incremental(incr.MurmurHash128x64), 'MurmurHash128x64 '] -]; - -if (program.crypto) { - crypto.getHashes().forEach(function(cipher) { - var pad = ' '; - funmatrix.push([ - function(data, encoding) { return cryptohasher(cipher, data, encoding); }, - cipher + pad.substr(0, pad.length - cipher.length) - ]); - }); -} - -function fillrandom(buffer) { - for(var i = 0; i < buffer.length; ++i) - buffer[i] = (Math.random()*0x100)|0; - return buffer; -} - -function randomstring(length) { - var buffer = fillrandom(Buffer.allocUnsafe(length)); - return buffer.toString('binary'); -} - -function bench(size, inputStr, duration) { - var input = inputStr - ? randomstring(size) - : fillrandom(Buffer.allocUnsafe(size)); - funmatrix.forEach(function(args) { - var fun = args[0], name = args[1]; - measure(inputStr ? "string" : "buffer", fun, name, duration, size, input); - }); -} - -bench(program.small, true, duration); -bench(program.large*1024, true, duration); -bench(program.large*1024, false, duration); - -function measure(label, fun, name, duration, size, arg) { - var cb = function(){ fun(arg, stringEncoding, outputType); }; - var iters = ben.calibrate(duration, cb); - var ms = ben(iters, cb); - console.log(name + "(" + label + "[" + size + "]): %s %s", - (size / ms / 1000).toFixed(4) + 'MB/s', - fun(arg, stringEncoding, outputType)); -} diff --git a/packages/node-murmurhash-native/bench/bench.stream.js b/packages/node-murmurhash-native/bench/bench.stream.js deleted file mode 100644 index c9a266a..0000000 --- a/packages/node-murmurhash-native/bench/bench.stream.js +++ /dev/null @@ -1,156 +0,0 @@ -#!/usr/bin/env node -// jshint eqnull:true -"use strict"; - -var os = require('os') - , fs = require('fs') - , crypto = require('crypto') - , stream = require('stream') - , util = require('util') - , parben = require('./parben').parallel - , strm = require('../stream') - , pipes = 1 - , parallel = os.cpus().length -; -var Readable = stream.Readable; -util.inherits(RandomStream, Readable); - -var program = require('commander'); - -program - .version(require(__dirname + '/../package.json').version) - .usage('[options] [pipes=1]') - .option('-n, --no-crypto', 'do not benchmark crypto hashers') - .option('-p, --parallel ', 'number of parallel streams', parseInt) - .option('-r, --random ', 'size of random streams in megabytes', 64) - .option('-f, --file ', 'file size in megabytes', 2048) - .option('-s, --small ', 'smallest random chunk', 1) - .option('-l, --large ', 'largest random chunk', 16384) - .parse(process.argv); - -if (program.args.length > 0) pipes = program.args[0]>>>0; - -if (program.parallel) { - parallel = Math.max(0, program.parallel>>>0); -} - -console.log('parallel streams: x%d', parallel); -console.log('parallel pipes: x%d', pipes); -console.log('smallest random chunk: %d', +program.small); -console.log(' largest random chunk: %d', +program.large); - -var funmatrix = [ - ['murmurhash', 'MurmurHash ', strm], - ['murmurhash128x86', 'MurmurHash128x86 ', strm], - ['murmurhash128x64', 'MurmurHash128x64 ', strm], -]; - -if (program.crypto) { - crypto.getHashes().forEach(function(cipher) { - var pad = ' '; - funmatrix.push([cipher, cipher + pad.substr(0, pad.length - cipher.length), crypto]); - }); -} - -var queued = []; - -function RandomStream(options) { - this.size = +options.size; - this.minchunk = null == options.minchunk ? 65536 : options.minchunk; - var maxchunk = null == options.maxchunk ? 65536 : options.maxchunk; - this.topchunk = maxchunk - this.minchunk + 1; - this.pending = 0; - Readable.call(this, options); -} - -RandomStream.prototype._read = function() { - var self = this; - var chunksize = Math.min(this.size, this.topchunk > 1 ? (Math.random()*this.topchunk|0) + this.minchunk : this.minchunk); - if (!chunksize) return; - this.size -= chunksize; - this.pending += chunksize; - crypto.randomBytes(chunksize, function(err, data) { - if (err) throw err; - var okmore = self.push(data); - self.pending -= chunksize; - if (!self.pending && !self.size) { - self.push(null); - } else if (okmore) { - self._read(); - } - }); -}; - -function benchRandomChunks(fun, name, hash, size, maxchunk, minchunk) { - measure('rndchunks', name, size, parben(parallel, parallel, function(next) { - var chunks = new RandomStream({maxchunk: maxchunk, minchunk: minchunk, size: size}); - for(var i = 0; i < pipes; ++i) { - chunks.pipe(hash.createHash(fun, {encoding: 'hex'})).once('readable', cb); - } - function cb() { if (!--i) next(); } - })); -} - -function createRandomFile(file, size, next) { - fs.stat(file, function(err, stat) { - var oldsize = err ? 0 : stat.size; - if (oldsize < size) { - new RandomStream({size: size - oldsize}).pipe(fs.createWriteStream(file, {start: oldsize})).on('finish', next); - } else { - next(); - } - }); -} - -function benchBigfile(file, fun, name, hash, size) { - measure('bigfile', name, size, parben(parallel, parallel, function(next) { - var fstrm = fs.createReadStream(file, {encoding:null}); - for(var i = 0; i < pipes; ++i) { - fstrm.pipe(hash.createHash(fun, {encoding: 'hex'})).once('readable', cb); - } - function cb() { if (!--i) next(); } - })); -} - -function benchRandomStream(fun, name, hash, size) { - measure('bigchunks', name, size, parben(parallel, parallel, function(next) { - var rstrm = new RandomStream({size: size}); - for(var i = 0; i < pipes; ++i) { - rstrm.pipe(hash.createHash(fun, {encoding: 'hex'})).once('readable', cb); - } - function cb() { if (!--i) next(); } - })); -} - -queue(createRandomFile, 'tmp-bigone.tmp', +program.file*1024*1024, next); - -funmatrix.forEach(function(row) { - queue(benchBigfile, 'tmp-bigone.tmp', row[0], row[1], row[2], program.file*1024*1024); -}); - -funmatrix.forEach(function(row) { - queue(benchRandomChunks, row[0], row[1], row[2], +program.random*1024*1024, +program.large, +program.small); -}); - -funmatrix.forEach(function(row) { - queue(benchRandomStream, row[0], row[1], row[2], +program.random*1024*1024); -}); - -next(); - -function measure(label, name, size, promise) { - promise.then(function(res) { - console.log(name + "(" + label + "[" + size + "]): single: %s avg: %s", - (size / res.single / 1000).toFixed(4) + 'MB/s', - (size / res.avg / 1000).toFixed(4) + 'MB/s'); - next(); - }); -} - -function queue() { - queued.push([].slice.call(arguments, 0)); -} - -function next() { - if (queued.length > 0) setImmediate.apply(null, queued.shift()); -} diff --git a/packages/node-murmurhash-native/bench/parben.js b/packages/node-murmurhash-native/bench/parben.js deleted file mode 100644 index 7383948..0000000 --- a/packages/node-murmurhash-native/bench/parben.js +++ /dev/null @@ -1,78 +0,0 @@ -"use strict"; - -var Promise = require('bluebird'); - -var now = Date.now; -var ben = module.exports = function(times, cb) { - if ('function' === typeof times) { - cb = times; - times = 10000; - } - - var t0 = now(); - for(var i = times; i-- > 0; cb()); - var elapsed = now() - t0; - return elapsed / times; -}; - -ben.sync = ben; - -ben.calibrate = function(duration, cb) { - var times = 5; - var elapsed = 100; - do { - times = (elapsed > 0 ? (100/elapsed)*times+times : 2*times) >>> 0; - var t0 = now(); - for(var i = times; i-- > 0; cb()); - elapsed = now() - t0; - } while(elapsed < 100); - - return Math.max(1, duration * times / elapsed) >>> 0; -}; - -var parben = ben.parallel = function(times, parallel, cb) { - return new Promise(function(resolve) { - if (times < parallel) parallel = times; - var pending = times>>>0; - var start = now(); - var elapsed = 0; - - function spawn() { - var t = now(); - cb(function fn () { - var fin = now(); - elapsed += fin - t; - - if (--pending === 0) { - resolve({elapsed: elapsed, single: elapsed / times, - wall: (fin - start), avg: (fin - start) / times}); - } - else if (pending >= parallel) { - t = now(); - cb(fn); - } - }); - } - - for(var i = parallel; i-- > 0; spawn()); - - }); -}; - -ben.parallel.calibrate = function(duration, parallel, cb) { - return new Promise(function(resolve) { - var times = 5*parallel; - var elapsed = 100; - var calib = function() { - times = elapsed > 0 ? (100/elapsed)*times+times : 2*times; - parben(times, parallel, cb).then(function(res) { - elapsed = res.wall; - if (elapsed < 100) calib(); - else { - resolve(Math.max(1, duration * times / elapsed) >>> 0); - } - }); - }; - calib(); - }); -}; diff --git a/packages/node-murmurhash-native/binding.gyp b/packages/node-murmurhash-native/binding.gyp deleted file mode 100644 index 4b8f4b6..0000000 --- a/packages/node-murmurhash-native/binding.gyp +++ /dev/null @@ -1,88 +0,0 @@ -{ - 'targets': [ - { - 'target_name': 'murmurhash', - 'sources': [ - 'src/murmurhash/MurmurHash2.cpp', - 'src/murmurhash/PMurHash.cpp', - 'src/murmurhash/PMurHash128.cpp', - 'src/nodemurmurhash.cc' - ], - 'include_dirs': [ - " void): void; - /** - * Updates a internal state with the given data asynchronously. - * - * If the data is a string, an encoding of "utf8" is assumed. - * - * The hash will be updated asynchronously using libuv worker queue. - * - * @param data a chunk of data to calculate hash from. - * @param callback will be called when asynchronous operation completes. - */ - update(data: string|Buffer, callback: (err: Error) => void): void; - /** - * Updates a internal state with the given data. - * - * If the data is a string and encoding is not explicitly provided, - * an encoding of "utf8" is being assumed. - * - * @param data a chunk of data to calculate hash from. - * @param encoding of the data provided as a string. - */ - update(data: string|Buffer, encoding?: Encoding): this; - /** Digest byte order. */ - endianness: Endianness; - /** - * True if asynchronous update is in progress. - * - * When this property is true, trying to update, calculate digest, serialize or copy state will result in - * an error thrown from the related method. - */ - readonly isBusy: boolean; - /** The total (modulo 2^32) bytes of data provided so far. */ - readonly total: number; -} - -/** A factory interface for murmurhash incremental utility */ -export interface IMurHasherConstructor { - /** Size in bytes of the serialized hasher. */ - readonly SERIAL_BYTE_LENGTH: number; - /** - * Creates MurmurHash utility. - * - * The default seed is 0 and the endianness is set to "BE". - */ - new(): IMurHasher; - /** - * Creates MurmurHash utility. - * - * If not provided, the endianness is set to "BE". - * - * @param seed initial murmur hash seed as an unsigned 32-bit integer. - * @param endianness digest byte order: "BE", "LE" or "platform", optional. Default is "BE". - */ - new(seed: number, endianness?: Endianness): IMurHasher; - /** - * Creates MurmurHash utility. - * - * The initial state is taken from the serialized state. Throws an error if serial is incorrect. - * - * @param serial serialized state of the same MurmurHash type. - * @param endianness digest byte order: "BE", "LE" or "platform", optional. Default is "BE". - */ - new(serial: string|Buffer, endianness?: Endianness): IMurHasher; - /** - * Creates MurmurHash utility. - * - * The initial state is taken from another instance of murmur hash utility. - * Throws an error if incompatible hash is provided. - * - * @param hash an instance of another MurmurHash. - * @param endianness digest byte order: "BE", "LE" or "platform", optional. Default is hash.endianness. - */ - new(hash: IMurHasher, endianness?: Endianness): IMurHasher; -} - -/** @hidden An abstract base class for the murmurhash incremental utility. */ -declare abstract class IMurHasherBase implements IMurHasher { - /** Size in bytes of the serialized hasher. */ - static readonly SERIAL_BYTE_LENGTH: number; - readonly SERIAL_BYTE_LENGTH: number; - /** - * Creates MurmurHash utility. - * - * The default seed is 0 and the endianness is set to "BE". - */ - constructor(); - /** - * Creates MurmurHash utility. - * - * If not provided, the endianness is set to "BE". - * - * @param seed initial murmur hash seed as an unsigned 32-bit integer. - * @param endianness digest byte order: "BE", "LE" or "platform", optional. Default is "BE". - */ - constructor(seed: number, endianness?: Endianness); - /** - * Creates MurmurHash utility. - * - * The initial state is taken from the serialized state. Throws an error if serial is incorrect. - * - * @param serial serialized state of the same MurmurHash type. - * @param endianness digest byte order: "BE", "LE" or "platform", optional. Default is "BE". - */ - constructor(serial: string|Buffer, endianness?: Endianness); - /** - * Creates MurmurHash utility. - * - * The initial state is taken from another instance of murmur hash utility. - * Throws an error if incompatible hash is provided. - * - * @param hash an instance of another MurmurHash. - * @param endianness digest byte order: "BE", "LE" or "platform", optional. Default is hash.endianness. - */ - constructor(hash: IMurHasher, endianness?: Endianness); - copy(target: IMurHasher): IMurHasher; - digest(output: Buffer, offset?: number, length?: number): Buffer; - digest(outputType?: OutputType): number|string|Buffer; - toJSON(): string; - serialize(output: Buffer, offset?: number): Buffer; - serialize(): string; - update(data: string|Buffer, encoding: Encoding, callback: (err: Error) => void): void; - update(data: string|Buffer, callback: (err: Error) => void): void; - update(data: string|Buffer, encoding?: Encoding): this; - endianness: Endianness; - readonly isBusy: boolean; - readonly total: number; -} - -/** A murmurhash32 implementation of the murmur hash incremental utility */ -export class MurmurHash extends IMurHasherBase {} - -/** A murmurhash128 (os arch) implementation of the murmur hash incremental utility */ -export class MurmurHash128 extends IMurHasherBase { - digest(output: Buffer, offset?: number, length?: number): Buffer; - digest(outputType?: OutputType): string|Buffer; -} - -/** A murmurhash128x64 implementation of the murmur hash incremental utility */ -export class MurmurHash128x64 extends IMurHasherBase { - digest(output: Buffer, offset?: number, length?: number): Buffer; - digest(outputType?: OutputType): string|Buffer; -} - -/** A murmurhash128x86 implementation of the murmur hash incremental utility */ -export class MurmurHash128x86 extends IMurHasherBase { - digest(output: Buffer, offset?: number, length?: number): Buffer; - digest(outputType?: OutputType): string|Buffer; -} diff --git a/packages/node-murmurhash-native/incremental.js b/packages/node-murmurhash-native/incremental.js deleted file mode 100644 index 50d9abf..0000000 --- a/packages/node-murmurhash-native/incremental.js +++ /dev/null @@ -1,7 +0,0 @@ -/* expose pure incremental api */ -"use strict"; - -var binary = require('node-pre-gyp'); -var path = require('path'); -var binding_path = binary.find(path.resolve(path.join(__dirname,'./package.json'))); -module.exports = require(path.join(path.dirname(binding_path), 'murmurhashincremental.node')); diff --git a/packages/node-murmurhash-native/index.d.ts b/packages/node-murmurhash-native/index.d.ts deleted file mode 100644 index 751f052..0000000 --- a/packages/node-murmurhash-native/index.d.ts +++ /dev/null @@ -1,150 +0,0 @@ -/** - * `murmurhash-native` module. - * - * Example: - * - * ```ts - * import { murmurHash128x64 } from "murmurhash-native" - * - * console.log(murmurHash128x64("hash me!", 42)) - * ``` - * - * @module murmurhash-native - */ - -/** - * Indicates the form and encoding of the resulting hash and can be one of: - * - * - "base64" - base64 string - * - "binary" - binary string - * - "buffer" - a new Buffer object - * - "hex" - hexadecimal string - * - "number" - for 32-bit murmur hash an unsigned 32-bit integer, other hashes - hexadecimal string - */ -export type OutputType = "base64"|"binary"|"buffer"|"hex"|"number"; -/** - * The expected encoding of the provided data as a string. - */ -export type Encoding = "ascii"|"base64"|"binary"|"hex"|"ucs-2"|"ucs2"|"utf-16le"|"utf-8"|"utf16le"|"utf8"; - -/** An interface for murmurhash functions. */ -export interface MurmurHashFn { - (data: string|Buffer): number|string; - (data: string|Buffer, callback: (err: Error, res: number|string) => void): void; - (data: string|Buffer, output: Buffer, offset?: number, length?: number): Buffer; - (data: string|Buffer, output: Buffer, callback: (err: Error, res: Buffer) => void): void; - (data: string|Buffer, output: Buffer, offset: number, callback: (err: Error, res: Buffer) => void): void; - (data: string|Buffer, output: Buffer, offset: number, length: number, callback: (err: Error, res: Buffer) => void): void; - (data: string, encOrOutType: Encoding|OutputType, seed?: number): number|string|Buffer; - (data: string, encOrOutType: Encoding|OutputType, callback: (err: Error, res: number|string|Buffer) => void): void; - (data: string, encOrOutType: Encoding|OutputType, seed: number, callback: (err: Error, res: number|string|Buffer) => void): void; - (data: Buffer, outputType: OutputType, seed?: number): number|string|Buffer; - (data: Buffer, outputType: OutputType, callback: (err: Error, res: number|string|Buffer) => void): void; - (data: Buffer, outputType: OutputType, seed: number, callback: (err: Error, res: number|string|Buffer) => void): void; - (data: string|Buffer, seed: number): number|string; - (data: string|Buffer, seed: number, callback: (err: Error, res: number|string) => void): void; - (data: string|Buffer, seed: number, output: Buffer, offset?: number, length?: number): Buffer; - (data: string|Buffer, seed: number, output: Buffer, callback: (err: Error, res: Buffer) => void): void; - (data: string|Buffer, seed: number, output: Buffer, offset: number, callback: (err: Error, res: Buffer) => void): void; - (data: string|Buffer, seed: number, output: Buffer, offset: number, length: number, callback: (err: Error, res: Buffer) => void): void; - (data: string|Buffer, seed: number, outputType: OutputType): number|string|Buffer; - (data: string|Buffer, seed: number, outputType: OutputType, callback: (err: Error, res: number|string|Buffer) => void): void; - (data: string|Buffer, encoding: Encoding, outputType: OutputType): number|string|Buffer; - (data: string|Buffer, encoding: Encoding, outputType: OutputType, callback: (err: Error, res: number|string|Buffer) => void): void; - (data: string, encoding: Encoding, output: Buffer, offset?: number, length?: number): Buffer; - (data: string, encoding: Encoding, output: Buffer, callback: (err: Error, res: Buffer) => void): void; - (data: string, encoding: Encoding, output: Buffer, offset: number, callback: (err: Error, res: Buffer) => void): void; - (data: string, encoding: Encoding, output: Buffer, offset: number, length: number, callback: (err: Error, res: Buffer) => void): void; - (data: string, encoding: Encoding, seed: number): number|string; - (data: string, encoding: Encoding, seed: number, callback: (err: Error, res: number|string) => void): void; - (data: string, encoding: Encoding, seed: number, output: Buffer, offset?: number, length?: number): Buffer; - (data: string, encoding: Encoding, seed: number, output: Buffer, callback: (err: Error, res: Buffer) => void): void; - (data: string, encoding: Encoding, seed: number, output: Buffer, offset: number, callback: (err: Error, res: Buffer) => void): void; - (data: string, encoding: Encoding, seed: number, output: Buffer, offset: number, length: number, callback: (err: Error, res: Buffer) => void): void; - (data: string, encoding: Encoding, seed: number, outputType: OutputType): number|string|Buffer; - (data: string, encoding: Encoding, seed: number, outputType: OutputType, callback: (err: Error, res: number|string|Buffer) => void): void; -} - -/** - * An interface for murmurhash 32-bit functions. - * - * Functions of this type produce hashes as an unsigned 32-bit integers by default - * and for the "number" output type. - */ -export interface MurmurHashFnI extends MurmurHashFn { - (data: string|Buffer): number; - (data: string|Buffer, callback: (err: Error, res: number) => void): void; - (data: string|Buffer, seed: number): number; - (data: string|Buffer, seed: number, callback: (err: Error, res: number) => void): void; - (data: string, encoding: Encoding, seed: number): number; - (data: string, encoding: Encoding, seed: number, callback: (err: Error, res: number) => void): void; -} - -/** - * An interface for murmurhash 64/128-bit functions. - * - * Functions of this type produce hashes as a hexadecimal string by default - * and for the "number" output type. - */ -export interface MurmurHashFnH extends MurmurHashFn { - (data: string|Buffer): string; - (data: string|Buffer, callback: (err: Error, res: string) => void): void; - (data: string, encOrOutType: Encoding|OutputType, seed?: number): string|Buffer; - (data: string, encOrOutType: Encoding|OutputType, callback: (err: Error, res: string|Buffer) => void): void; - (data: string, encOrOutType: Encoding|OutputType, seed: number, callback: (err: Error, res: string|Buffer) => void): void; - (data: Buffer, outputType: OutputType, seed?: number): string|Buffer; - (data: Buffer, outputType: OutputType, callback: (err: Error, res: string|Buffer) => void): void; - (data: Buffer, outputType: OutputType, seed: number, callback: (err: Error, res: string|Buffer) => void): void; - (data: string|Buffer, seed: number): string; - (data: string|Buffer, seed: number, callback: (err: Error, res: string) => void): void; - (data: string|Buffer, seed: number, outputType: OutputType): string|Buffer; - (data: string|Buffer, seed: number, outputType: OutputType, callback: (err: Error, res: string|Buffer) => void): void; - (data: string|Buffer, encoding: Encoding, outputType: OutputType): string|Buffer; - (data: string|Buffer, encoding: Encoding, outputType: OutputType, callback: (err: Error, res: string|Buffer) => void): void; - (data: string, encoding: Encoding, seed: number): string; - (data: string, encoding: Encoding, seed: number, callback: (err: Error, res: string) => void): void; - (data: string, encoding: Encoding, seed: number, outputType: OutputType): string|Buffer; - (data: string, encoding: Encoding, seed: number, outputType: OutputType, callback: (err: Error, res: string|Buffer) => void): void; -} - -export const murmurHash: MurmurHashFnI; -export const murmurHash32: MurmurHashFnI; -export const murmurHash64: MurmurHashFnH; -export const murmurHash64x64: MurmurHashFnH; -export const murmurHash64x86: MurmurHashFnH; -export const murmurHash128: MurmurHashFnH; -export const murmurHash128x64: MurmurHashFnH; -export const murmurHash128x86: MurmurHashFnH; - -export namespace BE { - export const murmurHash: MurmurHashFnI; - export const murmurHash32: MurmurHashFnI; - export const murmurHash64: MurmurHashFnH; - export const murmurHash64x64: MurmurHashFnH; - export const murmurHash64x86: MurmurHashFnH; - export const murmurHash128: MurmurHashFnH; - export const murmurHash128x64: MurmurHashFnH; - export const murmurHash128x86: MurmurHashFnH; -} - -export namespace LE { - export const murmurHash: MurmurHashFnI; - export const murmurHash32: MurmurHashFnI; - export const murmurHash64: MurmurHashFnH; - export const murmurHash64x64: MurmurHashFnH; - export const murmurHash64x86: MurmurHashFnH; - export const murmurHash128: MurmurHashFnH; - export const murmurHash128x64: MurmurHashFnH; - export const murmurHash128x86: MurmurHashFnH; -} - -export namespace platform { - export const murmurHash: MurmurHashFnI; - export const murmurHash32: MurmurHashFnI; - export const murmurHash64: MurmurHashFnH; - export const murmurHash64x64: MurmurHashFnH; - export const murmurHash64x86: MurmurHashFnH; - export const murmurHash128: MurmurHashFnH; - export const murmurHash128x64: MurmurHashFnH; - export const murmurHash128x86: MurmurHashFnH; -} diff --git a/packages/node-murmurhash-native/index.js b/packages/node-murmurhash-native/index.js deleted file mode 100644 index a7aac91..0000000 --- a/packages/node-murmurhash-native/index.js +++ /dev/null @@ -1,6 +0,0 @@ -"use strict"; - -var binary = require('node-pre-gyp'); -var path = require('path'); -var binding_path = binary.find(path.resolve(path.join(__dirname,'./package.json'))); -module.exports = require(binding_path); diff --git a/packages/node-murmurhash-native/lazy_transform.js b/packages/node-murmurhash-native/lazy_transform.js deleted file mode 100644 index e62efbd..0000000 --- a/packages/node-murmurhash-native/lazy_transform.js +++ /dev/null @@ -1,42 +0,0 @@ -/* from nodejs lib/internal/streams/lazy_transform.js */ - -// LazyTransform is a special type of Transform stream that is lazily loaded. -// This is used for performance with bi-API-ship: when two APIs are available -// for the stream, one conventional and one non-conventional. -'use strict'; - -var stream = require('stream'); -var util = require('util'); - -module.exports = LazyTransform; - -function LazyTransform(options) { - this._options = options; -} -util.inherits(LazyTransform, stream.Transform); - -[ - '_readableState', - '_writableState', - '_transformState' -].forEach(function(prop, i, props) { - Object.defineProperty(LazyTransform.prototype, prop, { - get: function() { - stream.Transform.call(this, this._options); - this._writableState.decodeStrings = false; - this._writableState.defaultEncoding = 'binary'; - return this[prop]; - }, - set: function(val) { - Object.defineProperty(this, prop, { - value: val, - enumerable: true, - configurable: true, - writable: true - }); - }, - configurable: true, - enumerable: true - }); -}); - diff --git a/packages/node-murmurhash-native/package.json b/packages/node-murmurhash-native/package.json deleted file mode 100644 index 82c68d4..0000000 --- a/packages/node-murmurhash-native/package.json +++ /dev/null @@ -1,64 +0,0 @@ -{ - "name": "murmurhash-native", - "description": "MurmurHash (32,64,128)bit native bindings for nodejs", - "keywords": [ - "murmurhash", - "murmurhash3", - "murmurhash128", - "murmurhash32", - "murmurhash2", - "murmurhash64", - "progressive hash", - "PMurHash", - "PMurHash128", - "hash" - ], - "version": "3.5.0", - "license": "MIT", - "author": "Rafał Michalski ", - "contributors": [], - "homepage": "http://github.com/royaltm/node-murmurhash-native", - "repository": { - "type": "git", - "url": "git+https://github.com/royaltm/node-murmurhash-native.git" - }, - "scripts": { - "install": "node-pre-gyp install --fallback-to-build", - "test": "tap -C -Rclassic ./test/test*.js ./test/types/test*.js", - "test-ts": "tap -C -Rclassic ./test/types/test*.js", - "test-gc": "tap -Rspec --node-arg=--expose-gc ./test/persistent/test.gc.*.js", - "bench": "sh bench/bench.all.sh", - "rebuild": "node-pre-gyp rebuild", - "tsc": "tsc -p test/types", - "typedoc": "typedoc --tsconfig test/types/tsconfig.json index.d.ts promisify.d.ts incremental.d.ts stream.d.ts" - }, - "binary": { - "module_name": "murmurhash", - "module_path": "./lib/{configuration}/", - "host": "https://github.com/royaltm/node-murmurhash-native/releases/download/", - "remote_path": "v{version}" - }, - "main": "index.js", - "types": "index.d.ts", - "typeScriptVersion": "2.0", - "engines": { - "node": ">=6" - }, - "dependencies": { - "nan": "^2.14.1", - "node-pre-gyp": "^0.17.0" - }, - "devDependencies": { - "@types/bluebird": "^3.5.30", - "@types/node": "^13.13.2", - "bluebird": "^3.7.2", - "commander": "^5.0.0", - "murmurhash3js": "^3.0.1", - "node-pre-gyp-github": "1.4.3", - "tap": "^14.10.7", - "typedoc": "^0.17.4", - "typedoc-plugin-external-module-name": "^3.0.0", - "typedoc-plugin-sourcefile-url": "^1.0.6", - "typescript": "^3.8.3" - } -} diff --git a/packages/node-murmurhash-native/promisify.d.ts b/packages/node-murmurhash-native/promisify.d.ts deleted file mode 100644 index 184cfbc..0000000 --- a/packages/node-murmurhash-native/promisify.d.ts +++ /dev/null @@ -1,77 +0,0 @@ -/** - * `murmurhash-native/promisify` module. - * - * Example: - * - * ```ts - * import * as promisify from "murmurhash-native/promisify" - * - * const { murmurHash128x64Async } = promisify() - * murmurHash128x64Async("hash me!", 42).then(hash => console.log(hash)) - * ``` - * - * @module promisify - */ - -/***/ -import { Encoding, OutputType } from "./index" - -declare namespace promisify { - /** An interface for promisified murmurhash functions */ - export interface MurmurHashFnAsync { - (data: string|Buffer): PromiseLike; - (data: string|Buffer, output: Buffer, offset?: number, length?: number): PromiseLike; - (data: string, encOrOutType: Encoding|OutputType, seed?: number): PromiseLike; - (data: Buffer, outputType: OutputType, seed?: number): PromiseLike; - (data: string|Buffer, seed: number): PromiseLike; - (data: string|Buffer, seed: number, output: Buffer, offset?: number, length?: number): PromiseLike; - (data: string|Buffer, seed: number, outputType: OutputType): PromiseLike; - (data: string|Buffer, encoding: Encoding, outputType: OutputType): PromiseLike; - (data: string, encoding: Encoding, output: Buffer, offset?: number, length?: number): PromiseLike; - (data: string, encoding: Encoding, seed: number): PromiseLike; - (data: string, encoding: Encoding, seed: number, output: Buffer, offset?: number, length?: number): PromiseLike; - (data: string, encoding: Encoding, seed: number, outputType: OutputType): PromiseLike; - } - /** An interface for promisified murmurhash 32-bit functions */ - export interface MurmurHashFnAsyncI extends MurmurHashFnAsync { - (data: string|Buffer): PromiseLike; - (data: string|Buffer, seed: number): PromiseLike; - (data: string, encoding: Encoding, seed: number): PromiseLike; - } - /** An interface for promisified murmurhash 64/128-bit functions */ - export interface MurmurHashFnAsyncH extends MurmurHashFnAsync { - (data: string|Buffer): PromiseLike; - (data: string, encOrOutType: Encoding|OutputType, seed?: number): PromiseLike; - (data: Buffer, outputType: OutputType, seed?: number): PromiseLike; - (data: string|Buffer, seed: number): PromiseLike; - (data: string|Buffer, seed: number, outputType: OutputType): PromiseLike; - (data: string|Buffer, encoding: Encoding, outputType: OutputType): PromiseLike; - (data: string, encoding: Encoding, seed: number): PromiseLike; - (data: string, encoding: Encoding, seed: number, outputType: OutputType): PromiseLike; - } - - export interface MurmurHashAsyncNs { - readonly murmurHashAsync: MurmurHashFnAsyncI; - readonly murmurHash32Async: MurmurHashFnAsyncI; - readonly murmurHash64x64Async: MurmurHashFnAsyncH; - readonly murmurHash64x86Async: MurmurHashFnAsyncH; - readonly murmurHash128x64Async: MurmurHashFnAsyncH; - readonly murmurHash128x86Async: MurmurHashFnAsyncH; - readonly murmurHash64Async: MurmurHashFnAsyncH; - readonly murmurHash128Async: MurmurHashFnAsyncH; - } - - export interface MurmurHashAsyncNsRoot extends MurmurHashAsyncNs { - readonly BE: MurmurHashAsyncNs; - readonly LE: MurmurHashAsyncNs; - readonly platform: MurmurHashAsyncNs; - } -} -/** - * Returns all promisified murmur hash functions in their corresponding namespaces. - * - * @param promise optional Promise constructor - */ -declare function promisify(promise?: PromiseConstructorLike): promisify.MurmurHashAsyncNsRoot; - -export = promisify; diff --git a/packages/node-murmurhash-native/promisify.js b/packages/node-murmurhash-native/promisify.js deleted file mode 100644 index 828343a..0000000 --- a/packages/node-murmurhash-native/promisify.js +++ /dev/null @@ -1,53 +0,0 @@ -// jshint multistr:true, evil:true -"use strict"; - -var murmurhash = require('./index'); - -module.exports = function(promise) { - if (!promise) { - promise = global.Promise; - } - - if ('function' !== typeof promise) { - throw new Error("Promise constructor required"); - } - - var promisify = function(object) { - var value, hash = {}; - - for(var name in object) { - if (object.hasOwnProperty(name)) { - if (!!(value = object[name])) { - switch(typeof value) { - case 'function': - hash[name + 'Async'] = wrap(promise, value); - break; - case 'object': - hash[name] = promisify(value); - break; - } - } - } - } - return hash; - }; - - return promisify(murmurhash); -}; - -function wrap(promise, fn) { - return new Function('Promise', 'slice', 'fn', - 'return function ' + fn.name + 'Async() { \ - var cb, args = slice.call(arguments); \ - var promise = new Promise(function(resolve, reject) { \ - cb = function(err, res) { \ - if (err) reject(err); else { \ - resolve(res); \ - } \ - }; \ - }); \ - args.push(cb); \ - fn.apply(this, args); \ - return promise; \ - }')(promise, Array.prototype.slice, fn); -} diff --git a/packages/node-murmurhash-native/src/asyncworker.h b/packages/node-murmurhash-native/src/asyncworker.h deleted file mode 100644 index 2a1dbe6..0000000 --- a/packages/node-murmurhash-native/src/asyncworker.h +++ /dev/null @@ -1,35 +0,0 @@ -#if !defined(ASYNCWORKER_HEADER) -#define ASYNCWORKER_HEADER - -namespace MurmurHash { - using v8::Local; - using v8::Value; - using v8::String; - using v8::Uint32; - - template - class MurmurHashWorker : public Nan::AsyncWorker { - public: - NAN_INLINE MurmurHashWorker(Nan::Callback *callback); - NAN_INLINE MurmurHashWorker(Nan::Callback *callback, const OutputType outputType, const uint32_t seed, - Local key, const enum Nan::Encoding encoding, const bool validEncoding); - NAN_INLINE void SaveOutputBuffer(const Local &buffer, int32_t offset, int32_t length); - void Execute(); - void HandleOKCallback(); - void HandleErrorCallback(); - - private: - InputData data_; - OutputType outputType_; - uint32_t seed_; - int32_t offset_; - int32_t length_; - HashValueType hash_[HashLength]; - char dataBuffer[NODE_MURMURHASH_KEY_BUFFER_SIZE]; - }; - -} - -#include "asyncworker_impl.h" - -#endif \ No newline at end of file diff --git a/packages/node-murmurhash-native/src/asyncworker_impl.h b/packages/node-murmurhash-native/src/asyncworker_impl.h deleted file mode 100644 index 8b68fc9..0000000 --- a/packages/node-murmurhash-native/src/asyncworker_impl.h +++ /dev/null @@ -1,123 +0,0 @@ -#if !defined(ASYNCWORKER_HEADER) -# error 'asyncworker_impl.h' is not supposed to be included directly. Include 'asyncworker.h' instead. -#endif - -namespace MurmurHash { - namespace { - enum { kInputBufferIndex, kOutputBufferIndex }; - } - - template - NAN_INLINE MurmurHashWorker - ::MurmurHashWorker( - Nan::Callback *callback) - : Nan::AsyncWorker(callback), data_(dataBuffer), outputType_(UnknownOutputType), seed_(0) {} - - template - NAN_INLINE MurmurHashWorker - ::MurmurHashWorker( - Nan::Callback *callback, const OutputType outputType, const uint32_t seed, - Local key, const enum Nan::Encoding encoding, const bool validEncoding) - : Nan::AsyncWorker(callback), data_(dataBuffer), outputType_(outputType), seed_(seed) - // offset_(0), length_(0) - { - data_.Setup(key, encoding, validEncoding); - if (data_.IsFromBuffer()) - SaveToPersistent(kInputBufferIndex, key); - } - - template - NAN_INLINE void MurmurHashWorker - ::SaveOutputBuffer( - const Local &buffer, int32_t offset, int32_t length) - { - SaveToPersistent(kOutputBufferIndex, buffer); - offset_ = offset; - length_ = length; - } - - template - void MurmurHashWorker - ::Execute() - { - if ( ! data_.IsValid() ) - return SetErrorMessage(data_.Error()); - - switch(outputType_) { - case DefaultOutputType: - case NumberOutputType: - case HexStringOutputType: - case BinaryStringOutputType: - case Base64StringOutputType: - case BufferOutputType: - case ProvidedBufferOutputType: - HashFunction( (const void *) *data_, (int) data_.length(), seed_, (void *)hash_ ); - break; - - default: - SetErrorMessage("Unknown output type: should be \"number\", \"buffer\", \"binary\", \"base64\" or \"hex\""); - } - } - - template - void MurmurHashWorker - ::HandleOKCallback() - { - Nan::HandleScope scope; - Local argv[2] = { Nan::Null() }; - - switch(outputType_) { - case DefaultOutputType: - case NumberOutputType: - if (HashSize == sizeof(uint32_t)) { - argv[1] = Nan::New( (uint32_t) hash_[0] ); - } else { - argv[1] = HashToEncodedString( hash_, Nan::HEX ); - } - break; - - case HexStringOutputType: - argv[1] = HashToEncodedString( hash_, Nan::HEX ); - break; - - case BinaryStringOutputType: - argv[1] = HashToEncodedString( hash_, Nan::BINARY ); - break; - - case Base64StringOutputType: - argv[1] = HashToEncodedString( hash_, Nan::BASE64 ); - break; - - case BufferOutputType: - argv[1] = Nan::NewBuffer( HashSize ).ToLocalChecked(); - WriteHashBytes(hash_, (uint8_t *) node::Buffer::Data(argv[1])); - break; - - case ProvidedBufferOutputType: - argv[1] = GetFromPersistent(kOutputBufferIndex); - WriteHashToBuffer( - hash_, - node::Buffer::Data(argv[1]), - (int32_t) node::Buffer::Length(argv[1]), - offset_, - length_); - break; - - default: - void(0); - } - - callback->Call(2, argv, async_resource); - } - - template - void MurmurHashWorker - ::HandleErrorCallback() { - Nan::HandleScope scope; - - Local argv[] = { - v8::Exception::TypeError(Nan::New(ErrorMessage()).ToLocalChecked()) - }; - callback->Call(1, argv, async_resource); - } -} diff --git a/packages/node-murmurhash-native/src/incremental/asyncupdate.h b/packages/node-murmurhash-native/src/incremental/asyncupdate.h deleted file mode 100644 index cde113a..0000000 --- a/packages/node-murmurhash-native/src/incremental/asyncupdate.h +++ /dev/null @@ -1,29 +0,0 @@ -#if !defined(ASYNCUPDATE_HEADER) -#define ASYNCUPDATE_HEADER - -namespace MurmurHash { - using v8::Local; - using v8::Value; - - template