Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x, 14.x, 16.x, 18.x, 20.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: node ./test.js
# - run: npm run build --if-present
# - run: npm run test
31 changes: 31 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: Node.js CI

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [14.x, 16.x, 18.x, 20.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build --if-present
- run: node ./test.js
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ npm install murmurhash
```

```js
murmurhash = require('murmurhash')
const murmurhash = require('murmurhash');
```
or

```js
import murmurhash from 'murmurhash';
```

Both version 2 and 3 of the MurmurHash algorithm are supported:
Expand Down
12 changes: 6 additions & 6 deletions murmurhash.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(function(){
var _global = this;
const _global = this;

const createBuffer = (val) => new TextEncoder().encode(val)

Expand All @@ -17,7 +17,7 @@
*/
function MurmurHashV2(str, seed) {
if (typeof str === 'string') str = createBuffer(str);
var
let
l = str.length,
h = seed ^ l,
i = 0,
Expand Down Expand Up @@ -54,7 +54,7 @@
return h >>> 0;
};

/**
/*
* JS Implementation of MurmurHash3 (r136) (as of May 20, 2011)
*
* @author <a href="mailto:gary.court@gmail.com">Gary Court</a>
Expand All @@ -69,7 +69,7 @@
function MurmurHashV3(key, seed) {
if (typeof key === 'string') key = createBuffer(key);

var remainder, bytes, h1, h1b, c1, c1b, c2, c2b, k1, i;
let remainder, bytes, h1, h1b, c1, c1b, c2, c2b, k1, i;

remainder = key.length & 3; // key.length % 4
bytes = key.length - remainder;
Expand Down Expand Up @@ -120,14 +120,14 @@
return h1 >>> 0;
}

var murmur = MurmurHashV3;
const murmur = MurmurHashV3;
murmur.v2 = MurmurHashV2;
murmur.v3 = MurmurHashV3;

if (typeof(module) != 'undefined') {
module.exports = murmur;
} else {
var _previousRoot = _global.murmur;
const _previousRoot = _global.murmur;
murmur.noConflict = function() {
_global.murmur = _previousRoot;
return murmur;
Expand Down
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name" : "murmurhash",
"version" : "1.0.0",
"description" : "A Node.js module for the optimized JavaScript implementation of the MurmurHash algorithms.",
"author": {
"authors": {
"Gary Court": "gary.court@gmail.com",
"Derek Perez": "derek@derekperez.com"
},
Expand Down
2 changes: 1 addition & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ if (
fromStr !== 3017643002
) {
throw new Error(`Wrong output`);
}
} else console.dir('Test ended with cought 0 errors');