Skip to content

Commit

Permalink
feat: create murmurhash v3
Browse files Browse the repository at this point in the history
  • Loading branch information
bchelkowski committed Feb 24, 2024
1 parent 915986d commit e0e57f0
Show file tree
Hide file tree
Showing 11 changed files with 4,536 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# http://editorconfig.org

root = true

[*]
charset = UTF-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
14 changes: 14 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "plugin:@dazn/kopytko/recommended",
"plugins": ["@dazn/kopytko"],
"rules": {
"@dazn/kopytko/dependencies-order": "error",
"@dazn/kopytko/missing-trailing-comma": "error",
"@dazn/kopytko/indent": ["error", 2],
"@dazn/kopytko/no-print": "off",
"@dazn/kopytko/no-stop": "error",
"@dazn/kopytko/sub-to-function": "error",
"@dazn/kopytko/function-no-return": "error",
"@dazn/kopytko/no-uninitialized-variables": "off"
}
}
27 changes: 27 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Release
on:
push:
branches:
- main
jobs:
release:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: Semantic Release
id: release
uses: cycjimmy/semantic-release-action@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
with:
extra_plugins: |
@semantic-release/changelog@6
@semantic-release/git@10
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.DS_Store
.env
.idea/
.vscode/

dist/
node_modules/
8 changes: 8 additions & 0 deletions .kopytkorc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"baseManifest": "./node_modules/@dazn/kopytko-unit-testing-framework/manifest.js",
"sourceDir": "./src",
"pluginDefinitions": {
"generate-tests": "./node_modules/@dazn/kopytko-unit-testing-framework/plugins/generate-tests"
},
"plugins": ["kopytko-copy-external-dependencies", "generate-tests"]
}
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,45 @@
# murmurhash-roku

BrightScript implementation of MurmurHash

The implementation is based on the following definition:
https://en.wikipedia.org/wiki/MurmurHash#Algorithm

## Installation

### with kopytko-packager

When using [kopytko-packager](https://github.com/getndazn/kopytko-packager) you can simly define this package as a dependecy.

`npm i murmurhash-roku`

### without kopytko-packager

Copy `MurmurHash.brs` file from this repository to your project.

**Remember that it uses also the `getType` function from the `kopytko-utils`, [so copy it along with it](https://github.com/getndazn/kopytko-utils/blob/master/src/components/getType.brs), or create a similar one.**

## Usage

```brightscript
' @import /components/libs/MurmurHash.brs from murmurhash-roku
function get123Hash() as LongInteger
return MurmurHash().v3("123", 1)
end function
```

## Documentation

Currently, there is only one hash method - v3.
It generates MurmurHash v3.
As Brightscript has only 32 or 64 signed values (Integer and LongInteger) this supports only 32-bit generation.

`MurmurHash().v3(key, seed)`

params:

- key - String or ByteArray to be hashed
- seed - accepts LongInteger, but it can be also an Integer

returns: (**LongInteger**) hashed value **LongInteger** value hash
Loading

0 comments on commit e0e57f0

Please sign in to comment.