-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from ashvardanian/25-nodejs-bindings-and-an-np…
…m-package NodeJS bindings
- Loading branch information
Showing
10 changed files
with
224 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: CI | ||
on: | ||
pull_request: | ||
branches: '*' | ||
push: | ||
branches: '*' | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [18.x] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Use Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18.x' | ||
- run: npm i | ||
- run: npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import test from 'node:test'; | ||
import bindings from 'bindings'; | ||
import assert from 'node:assert'; | ||
|
||
const stringzilla = bindings('stringzilla'); | ||
|
||
test('Count Words - Single Occurrence', () => { | ||
const result = stringzilla.count('hello world', 'world'); | ||
|
||
assert.strictEqual(result, 1n); | ||
}); | ||
|
||
test('Count Words - Multiple Occurrence', () => { | ||
const result = stringzilla.count('hello world, hello John', 'hello'); | ||
|
||
assert.strictEqual(result, 2n); | ||
}); | ||
|
||
test('Count Words - Multiple Occurrences with Overlap Test', () => { | ||
const result_1 = stringzilla.count('abababab', 'aba'); | ||
|
||
assert.strictEqual(result_1, 2n); | ||
|
||
const result_2 = stringzilla.count('abababab', 'aba', true); | ||
|
||
assert.strictEqual(result_2, 3n); | ||
}); | ||
|
||
test('Count Words - No Occurrence', () => { | ||
const result = stringzilla.count('hello world', 'hi'); | ||
|
||
assert.strictEqual(result, 0n); | ||
}); | ||
|
||
test('Count Words - Empty String Inputs', () => { | ||
const result_1 = stringzilla.count('hello world', ''); | ||
assert.strictEqual(result_1, 0n); | ||
|
||
const result_2 = stringzilla.count('', 'hi'); | ||
assert.strictEqual(result_2, 0n); | ||
|
||
const result_3 = stringzilla.count('', ''); | ||
assert.strictEqual(result_3, 0n); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import test from 'node:test'; | ||
import bindings from 'bindings'; | ||
import assert from 'node:assert'; | ||
|
||
const stringzilla = bindings('stringzilla'); | ||
|
||
test('Find Word in Text - Positive Case', () => { | ||
const result = stringzilla.find('hello world, hello john', 'hello'); | ||
|
||
assert.strictEqual(result, 0n); | ||
}); | ||
|
||
test('Find Word in Text - Negative Case (Word Not Found)', () => { | ||
const result_1 = stringzilla.find('ha', 'aaa'); | ||
assert.strictEqual(result_1, -1n); | ||
|
||
const result_2 = stringzilla.find('g', 'a'); | ||
assert.strictEqual(result_2, -1n); | ||
}); | ||
|
||
test('Find Word in Text - Negative Case (Empty String Inputs)', () => { | ||
const result_1 = stringzilla.find('hello world', ''); | ||
assert.strictEqual(result_1, 0n); | ||
|
||
const result_2 = stringzilla.find('', 'a'); | ||
assert.strictEqual(result_2, -1n); | ||
|
||
const result_3 = stringzilla.find('', ''); | ||
assert.strictEqual(result_2, -1n); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters