Compare commits
27 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 58109bd7e0 | |||
| afbeb7456f | |||
| 76926a2170 | |||
| a24a02fc97 | |||
| d3fd86a1fa | |||
| 70a34bf467 | |||
| 45951d2610 | |||
| 283703ec78 | |||
| 4fc2eb6ece | |||
| d647706881 | |||
| 9a6afa4531 | |||
| 039190e681 | |||
| be02f01959 | |||
| df0930e984 | |||
| 753dea9d96 | |||
| ff512a0284 | |||
| 4eead78c55 | |||
| fa262af6a4 | |||
| 58f7458acd | |||
| 34d8c86856 | |||
| d4cea26fb5 | |||
| de87e314c0 | |||
| cddd1163ec | |||
| 0fb86bc21b | |||
| cb5a24320c | |||
| cbc72cd55b | |||
| a2d8f9575d |
66
.gitea/workflows/default_nottags.yaml
Normal file
66
.gitea/workflows/default_nottags.yaml
Normal file
@@ -0,0 +1,66 @@
|
||||
name: Default (not tags)
|
||||
|
||||
on:
|
||||
push:
|
||||
tags-ignore:
|
||||
- '**'
|
||||
|
||||
env:
|
||||
IMAGE: code.foss.global/host.today/ht-docker-node:npmci
|
||||
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{gitea.repository}}.git
|
||||
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||
|
||||
jobs:
|
||||
security:
|
||||
runs-on: ubuntu-latest
|
||||
continue-on-error: true
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install pnpm and npmci
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @ship.zone/npmci
|
||||
|
||||
- name: Run npm prepare
|
||||
run: npmci npm prepare
|
||||
|
||||
- name: Audit production dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --prod
|
||||
continue-on-error: true
|
||||
|
||||
- name: Audit development dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --dev
|
||||
continue-on-error: true
|
||||
|
||||
test:
|
||||
if: ${{ always() }}
|
||||
needs: security
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Test stable
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm test
|
||||
|
||||
- name: Test build
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm build
|
||||
124
.gitea/workflows/default_tags.yaml
Normal file
124
.gitea/workflows/default_tags.yaml
Normal file
@@ -0,0 +1,124 @@
|
||||
name: Default (tags)
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
env:
|
||||
IMAGE: code.foss.global/host.today/ht-docker-node:npmci
|
||||
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@/${{gitea.repository}}.git
|
||||
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||
|
||||
jobs:
|
||||
security:
|
||||
runs-on: ubuntu-latest
|
||||
continue-on-error: true
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @ship.zone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Audit production dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --prod
|
||||
continue-on-error: true
|
||||
|
||||
- name: Audit development dependencies
|
||||
run: |
|
||||
npmci command npm config set registry https://registry.npmjs.org
|
||||
npmci command pnpm audit --audit-level=high --dev
|
||||
continue-on-error: true
|
||||
|
||||
test:
|
||||
if: ${{ always() }}
|
||||
needs: security
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @ship.zone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Test stable
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm test
|
||||
|
||||
- name: Test build
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
npmci npm build
|
||||
|
||||
release:
|
||||
needs: test
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @ship.zone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Release
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm publish
|
||||
|
||||
metadata:
|
||||
needs: test
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: ${{ env.IMAGE }}
|
||||
continue-on-error: true
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare
|
||||
run: |
|
||||
pnpm install -g pnpm
|
||||
pnpm install -g @ship.zone/npmci
|
||||
npmci npm prepare
|
||||
|
||||
- name: Code quality
|
||||
run: |
|
||||
npmci command npm install -g typescript
|
||||
npmci npm install
|
||||
|
||||
- name: Trigger
|
||||
run: npmci trigger
|
||||
|
||||
- name: Build docs and upload artifacts
|
||||
run: |
|
||||
npmci node install stable
|
||||
npmci npm install
|
||||
pnpm install -g @git.zone/tsdoc
|
||||
npmci command tsdoc
|
||||
continue-on-error: true
|
||||
19
.gitignore
vendored
19
.gitignore
vendored
@@ -1,6 +1,21 @@
|
||||
.nogit/
|
||||
node_modules/
|
||||
|
||||
# artifacts
|
||||
coverage/
|
||||
public/
|
||||
pages/
|
||||
|
||||
# installs
|
||||
node_modules/
|
||||
|
||||
# caches
|
||||
.yarn/
|
||||
.cache/
|
||||
.rpt2_cache
|
||||
|
||||
# builds
|
||||
dist/
|
||||
dist_*/
|
||||
|
||||
#------# custom
|
||||
**/.claude/settings.local.json
|
||||
.serena/
|
||||
|
||||
142
.gitlab-ci.yml
142
.gitlab-ci.yml
@@ -1,142 +0,0 @@
|
||||
# gitzone standard
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
|
||||
cache:
|
||||
paths:
|
||||
- .npmci_cache/
|
||||
key: "$CI_BUILD_STAGE"
|
||||
|
||||
stages:
|
||||
- security
|
||||
- test
|
||||
- release
|
||||
- metadata
|
||||
|
||||
# ====================
|
||||
# security stage
|
||||
# ====================
|
||||
mirror:
|
||||
stage: security
|
||||
script:
|
||||
- npmci git mirror
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
snyk:
|
||||
stage: security
|
||||
script:
|
||||
- npmci command npm install -g snyk
|
||||
- npmci command npm install --ignore-scripts
|
||||
- npmci command snyk test
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
# ====================
|
||||
# test stage
|
||||
# ====================
|
||||
testLEGACY:
|
||||
stage: test
|
||||
script:
|
||||
- npmci node install legacy
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
allow_failure: true
|
||||
|
||||
testLTS:
|
||||
stage: test
|
||||
script:
|
||||
- npmci node install lts
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
testSTABLE:
|
||||
stage: test
|
||||
script:
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci node install stable
|
||||
- npmci npm publish
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
# ====================
|
||||
# metadata stage
|
||||
# ====================
|
||||
codequality:
|
||||
stage: metadata
|
||||
image: docker:stable
|
||||
allow_failure: true
|
||||
services:
|
||||
- docker:stable-dind
|
||||
script:
|
||||
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
||||
- docker run
|
||||
--env SOURCE_CODE="$PWD"
|
||||
--volume "$PWD":/code
|
||||
--volume /var/run/docker.sock:/var/run/docker.sock
|
||||
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
|
||||
artifacts:
|
||||
paths: [codeclimate.json]
|
||||
tags:
|
||||
- docker
|
||||
- priv
|
||||
|
||||
trigger:
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci trigger
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
pages:
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci command npm install -g typedoc typescript
|
||||
- npmci npm install
|
||||
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
only:
|
||||
- tags
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- public
|
||||
allow_failure: true
|
||||
|
||||
windowsCompatibility:
|
||||
image: stefanscherer/node-windows:10-build-tools
|
||||
stage: metadata
|
||||
script:
|
||||
- npm install & npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- windows
|
||||
allow_failure: true
|
||||
11
.vscode/launch.json
vendored
Normal file
11
.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"command": "npm test",
|
||||
"name": "Run npm test",
|
||||
"request": "launch",
|
||||
"type": "node-terminal"
|
||||
}
|
||||
]
|
||||
}
|
||||
26
.vscode/settings.json
vendored
Normal file
26
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"json.schemas": [
|
||||
{
|
||||
"fileMatch": ["/npmextra.json"],
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"npmci": {
|
||||
"type": "object",
|
||||
"description": "settings for npmci"
|
||||
},
|
||||
"gitzone": {
|
||||
"type": "object",
|
||||
"description": "settings for gitzone",
|
||||
"properties": {
|
||||
"projectType": {
|
||||
"type": "string",
|
||||
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
97
changelog.md
Normal file
97
changelog.md
Normal file
@@ -0,0 +1,97 @@
|
||||
# Changelog
|
||||
|
||||
## 2025-08-05 - 2.0.0 - BREAKING_CHANGE(api)
|
||||
Major API cleanup and comprehensive documentation overhaul
|
||||
|
||||
### BREAKING CHANGES
|
||||
- **Removed deprecated methods**: `getChangeScoreForString()` and `getClosestMatchForString()` are no longer available
|
||||
- **Use modern API instead**: `calculateScores()` and `findClosestMatch()` respectively
|
||||
- **Improved type safety**: `findClosestMatch()` now correctly returns `string | null`
|
||||
|
||||
### Features
|
||||
- **Comprehensive documentation**: Complete readme overhaul with professional examples
|
||||
- **New sections added**: Quick Start, Performance Guide, Error Handling, Troubleshooting, API Reference
|
||||
- **Real-world examples**: Search-as-you-type, data deduplication, e-commerce search, recommendations
|
||||
- **Browser compatibility info**: Environment requirements and bundle size details
|
||||
- **Advanced configuration**: Fuse.js customization guidance
|
||||
|
||||
### Improvements
|
||||
- **Enhanced error handling**: Better graceful degradation patterns
|
||||
- **Performance guidance**: Time complexity analysis and optimization tips
|
||||
- **Modern developer experience**: Updated examples with current best practices
|
||||
- **Type-safe APIs**: Consistent null handling across all methods
|
||||
|
||||
## 2025-05-13 - 1.1.10 - fix(documentation)
|
||||
Update documentation and migration guide with standardized method names and deprecation notices.
|
||||
|
||||
- Replaced deprecated getClosestMatchForString with findClosestMatch in code examples.
|
||||
- Replaced deprecated getChangeScoreForString with calculateScores in documentation.
|
||||
- Updated readme plan to mark method naming standardization as completed.
|
||||
|
||||
## 2025-05-12 - 1.1.9 - fix(core)
|
||||
Update build scripts, refine testing assertions, and enhance documentation
|
||||
|
||||
- Updated .gitignore to exclude local settings files
|
||||
- Modified build script in package.json to use 'tsbuild tsfolders --allowimplicitany'
|
||||
- Revised readme.plan.md with comprehensive Fuse.js optimization and API improvement strategies
|
||||
- Enhanced input validation, error handling, and JSDoc comments across core classes
|
||||
- Standardized test syntax and improved test coverage for fuzzy matching features
|
||||
|
||||
## 2025-05-12 - 1.1.8 - fix(tests)
|
||||
Standardize test syntax and update testing dependencies
|
||||
|
||||
- Added @git.zone/tsrun dependency to package.json for improved test runner support
|
||||
- Refactored test export in test/test.articlesearch.ts to use default export instead of tap.start()
|
||||
- Updated readme.plan.md to describe testing improvements and syntax standardization
|
||||
|
||||
## 2025-05-12 - 1.1.7 - fix(build)
|
||||
Fix import paths, update CI workflows and upgrade dependencies for ESM compliance
|
||||
|
||||
- Updated import statements to include .js extensions for NodeNext compatibility
|
||||
- Upgraded dependencies: @push.rocks/smartpromise (^4.0.2), @tsclass/tsclass (^9.2.0), fuse.js (^7.1.0), leven (^4.0.0), and @push.rocks/tapbundle (^6.0.3)
|
||||
- Added new workflow files for CI (default_tags.yaml and default_nottags.yaml)
|
||||
- Revised test files and documentation to reflect file path and dependency changes
|
||||
- Minor adjustments in package.json (scripts and metadata) and tsconfig for enhanced module resolution
|
||||
|
||||
## 2024-05-29 - 1.1.6 - maintenance
|
||||
This release brings a series of configuration and documentation updates as well as an organizational change.
|
||||
- Updated project description.
|
||||
- Revised tsconfig settings.
|
||||
- Updated npmextra.json with new githost details (merged from several commits).
|
||||
- Switched to a new organization scheme.
|
||||
(Note: A prior commit “1.1.6” from 2021 was a version bump and is omitted here.)
|
||||
|
||||
## 2021-10-04 - 1.1.5 - core
|
||||
Core components were fixed in this update.
|
||||
- fix(core): update
|
||||
|
||||
## 2021-10-03 - 1.1.4
|
||||
This version was released as a version bump without additional significant changes.
|
||||
|
||||
## 2021-10-03 - 1.1.3 - core
|
||||
Minor fixes were applied to core functionality.
|
||||
- fix(core): update
|
||||
|
||||
## 2021-10-03 - 1.1.2 - core
|
||||
Additional improvements and fixes to the core components.
|
||||
- fix(core): update
|
||||
|
||||
## 2021-10-03 - 1.1.1 - core
|
||||
A further core update fixing underlying issues.
|
||||
- fix(core): update
|
||||
|
||||
## 2018-08-19 - 1.1.0 - Smartfuzzy
|
||||
A fix was introduced for Smartfuzzy’s matching functionality.
|
||||
- fix(Smartfuzzy.getClosestMatchForString() now returns the cloesest string directly): update
|
||||
|
||||
## 2018-08-19 - 1.0.3 - ObjectSorter
|
||||
A new feature has been added to sort objects by likability.
|
||||
- feat(ObjectSorter): now sorts objects by likability
|
||||
|
||||
## 2018-08-19 - 1.0.2 - package
|
||||
An adjustment was made to the package name in the npm configuration.
|
||||
- fix(package): npm name
|
||||
|
||||
## 2018-08-19 - 1.0.1 - package
|
||||
Initial package fixes were applied.
|
||||
- fix(package): initial
|
||||
19
license
Normal file
19
license
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2014 Lossless GmbH (hello@lossless.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.
|
||||
@@ -1,6 +1,33 @@
|
||||
{
|
||||
"gitzone": {
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "code.foss.global",
|
||||
"gitscope": "push.rocks",
|
||||
"gitrepo": "smartfuzzy",
|
||||
"shortDescription": "search things easily",
|
||||
"npmPackagename": "@push.rocks/smartfuzzy",
|
||||
"license": "MIT",
|
||||
"description": "A library for fuzzy matching strings against word dictionaries or arrays, with support for object and article searching.",
|
||||
"keywords": [
|
||||
"fuzzy matching",
|
||||
"string matching",
|
||||
"dictionary matching",
|
||||
"search",
|
||||
"text analysis",
|
||||
"object sorting",
|
||||
"article search",
|
||||
"text similarity",
|
||||
"keyword matching",
|
||||
"data filtering"
|
||||
]
|
||||
}
|
||||
},
|
||||
"npmci": {
|
||||
"npmGlobalTools": [],
|
||||
"npmAccessLevel": "public"
|
||||
},
|
||||
"tsdoc": {
|
||||
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
|
||||
}
|
||||
}
|
||||
}
|
||||
871
package-lock.json
generated
871
package-lock.json
generated
@@ -1,871 +0,0 @@
|
||||
{
|
||||
"name": "smartfuzzy",
|
||||
"version": "1.1.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"@airbnb/node-memwatch": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@airbnb/node-memwatch/-/node-memwatch-1.0.2.tgz",
|
||||
"integrity": "sha512-2R+MEEMSTUdKwQ6NFWkyA/UNoSjL1tMldZqJbZpgXSwNMBzlNlkUWEXKu9RqTTMkDqJRfGJ2VDs8gPlPK2APDQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"bindings": "^1.3.0",
|
||||
"nan": "^2.9.2"
|
||||
}
|
||||
},
|
||||
"@gitzone/tsbuild": {
|
||||
"version": "2.0.22",
|
||||
"resolved": "https://registry.npmjs.org/@gitzone/tsbuild/-/tsbuild-2.0.22.tgz",
|
||||
"integrity": "sha512-H0rqGVUKXWgxXhkY62kF92WpbS9GSJW27jQXaoyMsQptTQN4HIYKHWZMdO4egkk0/gDmKnBjk8MXg5Rx6efItA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@pushrocks/smartfile": "^6.0.6",
|
||||
"@pushrocks/smartlog": "^2.0.1",
|
||||
"@pushrocks/smartpath": "^4.0.1",
|
||||
"@pushrocks/smartpromise": "^2.0.5",
|
||||
"typescript": "^3.0.1"
|
||||
}
|
||||
},
|
||||
"@gitzone/tsrun": {
|
||||
"version": "1.1.12",
|
||||
"resolved": "https://registry.npmjs.org/@gitzone/tsrun/-/tsrun-1.1.12.tgz",
|
||||
"integrity": "sha512-DOxqOg+evoxhgbzhzH4u6LaPF+6bpMsnBVl1QQaHzKPGBlNjaIY4yJ0RsGnWMgX1hlNLvbgHtl0Ky4A2MDvyrg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@gitzone/tsbuild": "^2.0.22",
|
||||
"@pushrocks/smartfile": "^6.0.6",
|
||||
"ts-node": "^7.0.0",
|
||||
"typescript": "^3.0.1"
|
||||
}
|
||||
},
|
||||
"@gitzone/tstest": {
|
||||
"version": "1.0.15",
|
||||
"resolved": "https://registry.npmjs.org/@gitzone/tstest/-/tstest-1.0.15.tgz",
|
||||
"integrity": "sha512-+t5fvYK4a0JkwwH0Fokh5aOxVzrax5OjDUL4zmhBk7KFmXt7fdvcqsSNaEp9iyqC52dLiDybdAXqHYZypXTIYw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@gitzone/tsrun": "^1.1.12",
|
||||
"@pushrocks/consolecolor": "^2.0.1",
|
||||
"@pushrocks/smartfile": "^6.0.6",
|
||||
"@pushrocks/smartlog": "^2.0.1",
|
||||
"@pushrocks/smartpromise": "^2.0.5",
|
||||
"@pushrocks/smartshell": "^2.0.6",
|
||||
"@types/figures": "^2.0.0",
|
||||
"figures": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"@pushrocks/consolecolor": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@pushrocks/consolecolor/-/consolecolor-2.0.1.tgz",
|
||||
"integrity": "sha512-iOFCHVeFZ2OywbdwSxVI4/wokkcLrXVdHLgvMmkNhJ220eeLgjNZWx3EJo3vNW3zq5ybCSCUIq0878djBxrWpw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ansi-256-colors": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"@pushrocks/early": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@pushrocks/early/-/early-3.0.3.tgz",
|
||||
"integrity": "sha512-71/nwxTpqdp1glmHz4YaGusNl/XOOcPelAxC9RA6rpS/6280QyY2u4yx+mRdMrCzn7ruLYF5awbkS8llNZ94Pg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@pushrocks/consolecolor": "^2.0.1",
|
||||
"@pushrocks/smartpromise": "^2.0.5"
|
||||
}
|
||||
},
|
||||
"@pushrocks/smartdelay": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@pushrocks/smartdelay/-/smartdelay-2.0.2.tgz",
|
||||
"integrity": "sha512-4xf6tMKwZcxBynKgXrM4SQKgeASfRvx43LUmR5DkStp26ZHAsarCXUdKJS6y8QIPygEOTOCP8we97JAcCzBuMg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@pushrocks/smartpromise": "^2.0.5"
|
||||
}
|
||||
},
|
||||
"@pushrocks/smartfile": {
|
||||
"version": "6.0.6",
|
||||
"resolved": "https://registry.npmjs.org/@pushrocks/smartfile/-/smartfile-6.0.6.tgz",
|
||||
"integrity": "sha512-vA1+yS6n0kuBZ+Bl30rxOCYvgIj0mo9g303cUpOZR0I781iQVWHcBKRC05FaGDxJD1HuYdvbSK+7vlrzZjVcMw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@pushrocks/smartpath": "^4.0.1",
|
||||
"@pushrocks/smartpromise": "^2.0.5",
|
||||
"@pushrocks/smartrequest": "^1.1.12",
|
||||
"@types/fs-extra": "^5.0.4",
|
||||
"@types/vinyl": "^2.0.2",
|
||||
"fs-extra": "^7.0.0",
|
||||
"glob": "^7.1.2",
|
||||
"js-yaml": "^3.10.0",
|
||||
"vinyl-file": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"@pushrocks/smartlog": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@pushrocks/smartlog/-/smartlog-2.0.1.tgz",
|
||||
"integrity": "sha512-GtsDTGIUF3VuWPyF8FV5dF31ZCEIcaJ56ZlvJsWxjnyJq57X25mk5/K0QAaRE9IIeHg6fORcukFomb5C+AOQrg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@pushrocks/smartlog-interfaces": "^1.0.9"
|
||||
}
|
||||
},
|
||||
"@pushrocks/smartlog-interfaces": {
|
||||
"version": "1.0.9",
|
||||
"resolved": "https://registry.npmjs.org/@pushrocks/smartlog-interfaces/-/smartlog-interfaces-1.0.9.tgz",
|
||||
"integrity": "sha512-0qwpomrRN0kFjmhR9m1iHYXoISoNuXtRP0Wr+JtkYyURLwKHMaW8Xoznf8MzXJptRfqufJi3Fxh5HodpPrIZUA==",
|
||||
"dev": true
|
||||
},
|
||||
"@pushrocks/smartpath": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@pushrocks/smartpath/-/smartpath-4.0.1.tgz",
|
||||
"integrity": "sha512-MaI0+uLQPCr2V3WGnbdgb0pWa9xkWyrP4qYcbsHIjeismGLbn9s3jmP/HIXU8LkgzRgaVb+BJxmZJHOwl32DyA==",
|
||||
"dev": true
|
||||
},
|
||||
"@pushrocks/smartpromise": {
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://registry.npmjs.org/@pushrocks/smartpromise/-/smartpromise-2.0.5.tgz",
|
||||
"integrity": "sha512-9j/chLtIiNkR0MDw7Mpxg9slxAVvAQwUZuiaPYX5KpHdKxQaHLI1VZ8IN0vPhwlfgNO4i4vGXV0wB8BvSDj03g==",
|
||||
"dev": true
|
||||
},
|
||||
"@pushrocks/smartrequest": {
|
||||
"version": "1.1.14",
|
||||
"resolved": "https://registry.npmjs.org/@pushrocks/smartrequest/-/smartrequest-1.1.14.tgz",
|
||||
"integrity": "sha512-+sDQB4Mxvpn8BIMPUQ7TPSCKUVMln3tHC4rp4pmfEHmBQK+g1XwtNr59aMA9kEoBDMt7li1hu+1cs+SNsWt6Gw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@pushrocks/smartpromise": "^2.0.5",
|
||||
"@types/form-data": "^2.2.1",
|
||||
"form-data": "^2.3.2"
|
||||
}
|
||||
},
|
||||
"@pushrocks/smartshell": {
|
||||
"version": "2.0.6",
|
||||
"resolved": "https://registry.npmjs.org/@pushrocks/smartshell/-/smartshell-2.0.6.tgz",
|
||||
"integrity": "sha512-D48KB3DDqLfMjOXGEutqJi+v3Z4RcWacu5BJXxUwrecvd6oetbKobfmNGxeHSQPmNGb7U3ISfKwV6c5T5EZkJg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@pushrocks/smartpromise": "^2.0.5",
|
||||
"@types/which": "^1.3.1",
|
||||
"which": "^1.3.1"
|
||||
}
|
||||
},
|
||||
"@pushrocks/tapbundle": {
|
||||
"version": "3.0.5",
|
||||
"resolved": "https://registry.npmjs.org/@pushrocks/tapbundle/-/tapbundle-3.0.5.tgz",
|
||||
"integrity": "sha512-7K1y4pyJ5O8XRmnW/ADryEoniGKOW0Un6VZpxMcYTndS5AjwKhjRkAAaSQf4g/a8Ei+uk/q8csI9Twjb9KISLQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@pushrocks/early": "^3.0.3",
|
||||
"@pushrocks/smartdelay": "^2.0.2",
|
||||
"@pushrocks/smartpromise": "^2.0.5",
|
||||
"leakage": "^0.4.0",
|
||||
"smartchai": "^2.0.1"
|
||||
}
|
||||
},
|
||||
"@types/chai": {
|
||||
"version": "4.1.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.1.4.tgz",
|
||||
"integrity": "sha512-h6+VEw2Vr3ORiFCyyJmcho2zALnUq9cvdB/IO8Xs9itrJVCenC7o26A6+m7D0ihTTr65eS259H5/Ghl/VjYs6g==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/chai-as-promised": {
|
||||
"version": "7.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/chai-as-promised/-/chai-as-promised-7.1.0.tgz",
|
||||
"integrity": "sha512-MFiW54UOSt+f2bRw8J7LgQeIvE/9b4oGvwU7XW30S9QGAiHGnU/fmiOprsyMkdmH2rl8xSPc0/yrQw8juXU6bQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/chai": "*"
|
||||
}
|
||||
},
|
||||
"@types/chai-string": {
|
||||
"version": "1.4.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/chai-string/-/chai-string-1.4.1.tgz",
|
||||
"integrity": "sha512-aRNMs6TKgjgPlCHwDfq/YNy5VtRR2hJ4AUWByddrT0TRVVD8eX4MiHW6/iHvmQHRlVuuPZcwnTUE7b4yFt7bEA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/chai": "*"
|
||||
}
|
||||
},
|
||||
"@types/figures": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/figures/-/figures-2.0.0.tgz",
|
||||
"integrity": "sha512-mcRgJ+ncKuNI+Dwac7omO18B8C8u+YBS+AU/oyLhEyjAnT3cUUThhHgZpbiIvu5ZqSvdD30BXtrqg9nxc3OKMg==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/form-data": {
|
||||
"version": "2.2.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/form-data/-/form-data-2.2.1.tgz",
|
||||
"integrity": "sha512-JAMFhOaHIciYVh8fb5/83nmuO/AHwmto+Hq7a9y8FzLDcC1KCU344XDOMEmahnrTFlHjgh4L0WJFczNIX2GxnQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"@types/fs-extra": {
|
||||
"version": "5.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/fs-extra/-/fs-extra-5.0.4.tgz",
|
||||
"integrity": "sha512-DsknoBvD8s+RFfSGjmERJ7ZOP1HI0UZRA3FSI+Zakhrc/Gy26YQsLI+m5V5DHxroHRJqCDLKJp7Hixn8zyaF7g==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"@types/leven": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/leven/-/leven-2.1.1.tgz",
|
||||
"integrity": "sha512-f74SsCQnQzm244o5LHZgSLijrwG5e9BgkMHGbDlQThfh42q5RG4c+RNzUvZ347wAlQYD9kwu64qSNylxZdKs6w=="
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "10.7.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.7.1.tgz",
|
||||
"integrity": "sha512-EGoI4ylB/lPOaqXqtzAyL8HcgOuCtH2hkEaLmkueOYufsTFWBn4VCvlCDC2HW8Q+9iF+QVC3sxjDKQYjHQeZ9w==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/vinyl": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/vinyl/-/vinyl-2.0.2.tgz",
|
||||
"integrity": "sha512-2iYpNuOl98SrLPBZfEN9Mh2JCJ2EI9HU35SfgBEb51DcmaHkhp8cKMblYeBqMQiwXMgAD3W60DbQ4i/UdLiXhw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"@types/which": {
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/which/-/which-1.3.1.tgz",
|
||||
"integrity": "sha512-ZrJDWpvg75LTGX4XwuneY9s6bF3OeZcGTpoGh3zDV9ytzcHMFsRrMIaLBRJZQMBoGyKs6unBQfVdrLZiYfb1zQ==",
|
||||
"dev": true
|
||||
},
|
||||
"ansi-256-colors": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/ansi-256-colors/-/ansi-256-colors-1.1.0.tgz",
|
||||
"integrity": "sha1-kQ3lDvzHwJ49gvL4er1rcAwYgYo=",
|
||||
"dev": true
|
||||
},
|
||||
"argparse": {
|
||||
"version": "1.0.10",
|
||||
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
|
||||
"integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"sprintf-js": "~1.0.2"
|
||||
}
|
||||
},
|
||||
"arrify": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz",
|
||||
"integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=",
|
||||
"dev": true
|
||||
},
|
||||
"assertion-error": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz",
|
||||
"integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==",
|
||||
"dev": true
|
||||
},
|
||||
"asynckit": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
||||
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=",
|
||||
"dev": true
|
||||
},
|
||||
"balanced-match": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
|
||||
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
|
||||
"dev": true
|
||||
},
|
||||
"bindings": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.3.0.tgz",
|
||||
"integrity": "sha512-DpLh5EzMR2kzvX1KIlVC0VkC3iZtHKTgdtZ0a3pglBZdaQFjt5S9g9xd1lE+YvXyfd6mtCeRnrUfOLYiTMlNSw==",
|
||||
"dev": true
|
||||
},
|
||||
"brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
||||
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
}
|
||||
},
|
||||
"buffer-from": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
|
||||
"integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==",
|
||||
"dev": true
|
||||
},
|
||||
"chai": {
|
||||
"version": "4.1.2",
|
||||
"resolved": "https://registry.npmjs.org/chai/-/chai-4.1.2.tgz",
|
||||
"integrity": "sha1-D2RYS6ZC8PKs4oBiefTwbKI61zw=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"assertion-error": "^1.0.1",
|
||||
"check-error": "^1.0.1",
|
||||
"deep-eql": "^3.0.0",
|
||||
"get-func-name": "^2.0.0",
|
||||
"pathval": "^1.0.0",
|
||||
"type-detect": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"chai-as-promised": {
|
||||
"version": "7.1.1",
|
||||
"resolved": "https://registry.npmjs.org/chai-as-promised/-/chai-as-promised-7.1.1.tgz",
|
||||
"integrity": "sha512-azL6xMoi+uxu6z4rhWQ1jbdUhOMhis2PvscD/xjLqNMkv3BPPp2JyyuTHOrf9BOosGpNQ11v6BKv/g57RXbiaA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"check-error": "^1.0.2"
|
||||
}
|
||||
},
|
||||
"chai-string": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/chai-string/-/chai-string-1.4.0.tgz",
|
||||
"integrity": "sha1-NZFAwFHTak5LGl/GuRAVL0OKjUk=",
|
||||
"dev": true
|
||||
},
|
||||
"check-error": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz",
|
||||
"integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=",
|
||||
"dev": true
|
||||
},
|
||||
"clone": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/clone/-/clone-2.1.2.tgz",
|
||||
"integrity": "sha1-G39Ln1kfHo+DZwQBYANFoCiHQ18=",
|
||||
"dev": true
|
||||
},
|
||||
"clone-buffer": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/clone-buffer/-/clone-buffer-1.0.0.tgz",
|
||||
"integrity": "sha1-4+JbIHrE5wGvch4staFnksrD3Fg=",
|
||||
"dev": true
|
||||
},
|
||||
"clone-stats": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/clone-stats/-/clone-stats-1.0.0.tgz",
|
||||
"integrity": "sha1-s3gt/4u1R04Yuba/D9/ngvh3doA=",
|
||||
"dev": true
|
||||
},
|
||||
"cloneable-readable": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/cloneable-readable/-/cloneable-readable-1.1.2.tgz",
|
||||
"integrity": "sha512-Bq6+4t+lbM8vhTs/Bef5c5AdEMtapp/iFb6+s4/Hh9MVTt8OLKH7ZOOZSCT+Ys7hsHvqv0GuMPJ1lnQJVHvxpg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"inherits": "^2.0.1",
|
||||
"process-nextick-args": "^2.0.0",
|
||||
"readable-stream": "^2.3.5"
|
||||
}
|
||||
},
|
||||
"combined-stream": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz",
|
||||
"integrity": "sha1-cj599ugBrFYTETp+RFqbactjKBg=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"delayed-stream": "~1.0.0"
|
||||
}
|
||||
},
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
|
||||
"dev": true
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
|
||||
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=",
|
||||
"dev": true
|
||||
},
|
||||
"deep-eql": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz",
|
||||
"integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"type-detect": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"delayed-stream": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=",
|
||||
"dev": true
|
||||
},
|
||||
"diff": {
|
||||
"version": "3.5.0",
|
||||
"resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz",
|
||||
"integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==",
|
||||
"dev": true
|
||||
},
|
||||
"es6-error": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/es6-error/-/es6-error-4.1.1.tgz",
|
||||
"integrity": "sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==",
|
||||
"dev": true
|
||||
},
|
||||
"escape-string-regexp": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
|
||||
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=",
|
||||
"dev": true
|
||||
},
|
||||
"esprima": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
|
||||
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
|
||||
"dev": true
|
||||
},
|
||||
"figures": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz",
|
||||
"integrity": "sha1-OrGi0qYsi/tDGgyUy3l6L84nyWI=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"escape-string-regexp": "^1.0.5"
|
||||
}
|
||||
},
|
||||
"first-chunk-stream": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/first-chunk-stream/-/first-chunk-stream-2.0.0.tgz",
|
||||
"integrity": "sha1-G97NuOCDwGZLkZRVgVd6Q6nzHXA=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"readable-stream": "^2.0.2"
|
||||
}
|
||||
},
|
||||
"form-data": {
|
||||
"version": "2.3.2",
|
||||
"resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.2.tgz",
|
||||
"integrity": "sha1-SXBJi+YEwgwAXU9cI67NIda0kJk=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"asynckit": "^0.4.0",
|
||||
"combined-stream": "1.0.6",
|
||||
"mime-types": "^2.1.12"
|
||||
}
|
||||
},
|
||||
"fs-extra": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.0.tgz",
|
||||
"integrity": "sha512-EglNDLRpmaTWiD/qraZn6HREAEAHJcJOmxNEYwq6xeMKnVMAy3GUcFB+wXt2C6k4CNvB/mP1y/U3dzvKKj5OtQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"graceful-fs": "^4.1.2",
|
||||
"jsonfile": "^4.0.0",
|
||||
"universalify": "^0.1.0"
|
||||
}
|
||||
},
|
||||
"fs.realpath": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||
"integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
|
||||
"dev": true
|
||||
},
|
||||
"fuse.js": {
|
||||
"version": "3.2.1",
|
||||
"resolved": "https://registry.npmjs.org/fuse.js/-/fuse.js-3.2.1.tgz",
|
||||
"integrity": "sha1-YyDLlM5W7JdVyJred1vNuwNY1CU="
|
||||
},
|
||||
"get-func-name": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz",
|
||||
"integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=",
|
||||
"dev": true
|
||||
},
|
||||
"glob": {
|
||||
"version": "7.1.2",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz",
|
||||
"integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"fs.realpath": "^1.0.0",
|
||||
"inflight": "^1.0.4",
|
||||
"inherits": "2",
|
||||
"minimatch": "^3.0.4",
|
||||
"once": "^1.3.0",
|
||||
"path-is-absolute": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"graceful-fs": {
|
||||
"version": "4.1.11",
|
||||
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz",
|
||||
"integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=",
|
||||
"dev": true
|
||||
},
|
||||
"inflight": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
|
||||
"integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"once": "^1.3.0",
|
||||
"wrappy": "1"
|
||||
}
|
||||
},
|
||||
"inherits": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
|
||||
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
|
||||
"dev": true
|
||||
},
|
||||
"is-utf8": {
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz",
|
||||
"integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=",
|
||||
"dev": true
|
||||
},
|
||||
"isarray": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
|
||||
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=",
|
||||
"dev": true
|
||||
},
|
||||
"isexe": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
|
||||
"integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=",
|
||||
"dev": true
|
||||
},
|
||||
"js-yaml": {
|
||||
"version": "3.12.0",
|
||||
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.0.tgz",
|
||||
"integrity": "sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"argparse": "^1.0.7",
|
||||
"esprima": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"jsonfile": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz",
|
||||
"integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"graceful-fs": "^4.1.6"
|
||||
}
|
||||
},
|
||||
"leakage": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/leakage/-/leakage-0.4.0.tgz",
|
||||
"integrity": "sha512-x7gYK5n5dPkHDZWJ2Kh8Ag1hZNzUh+HtXn8Bv1aDdN6o6ONPCJ8sOfFq+kxcULJFp3lXaCjXb3iXOLmQRbBLwA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@airbnb/node-memwatch": "^1.0.2",
|
||||
"es6-error": "^4.0.2",
|
||||
"left-pad": "^1.1.3",
|
||||
"minimist": "^1.2.0",
|
||||
"pretty-bytes": "^4.0.2"
|
||||
}
|
||||
},
|
||||
"left-pad": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/left-pad/-/left-pad-1.3.0.tgz",
|
||||
"integrity": "sha512-XI5MPzVNApjAyhQzphX8BkmKsKUxD4LdyK24iZeQGinBN9yTQT3bFlCBy/aVx2HrNcqQGsdot8ghrjyrvMCoEA==",
|
||||
"dev": true
|
||||
},
|
||||
"leven": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/leven/-/leven-2.1.0.tgz",
|
||||
"integrity": "sha1-wuep93IJTe6dNCAq6KzORoeHVYA="
|
||||
},
|
||||
"make-error": {
|
||||
"version": "1.3.4",
|
||||
"resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.4.tgz",
|
||||
"integrity": "sha512-0Dab5btKVPhibSalc9QGXb559ED7G7iLjFXBaj9Wq8O3vorueR5K5jaE3hkG6ZQINyhA/JgG6Qk4qdFQjsYV6g==",
|
||||
"dev": true
|
||||
},
|
||||
"mime-db": {
|
||||
"version": "1.35.0",
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.35.0.tgz",
|
||||
"integrity": "sha512-JWT/IcCTsB0Io3AhWUMjRqucrHSPsSf2xKLaRldJVULioggvkJvggZ3VXNNSRkCddE6D+BUI4HEIZIA2OjwIvg==",
|
||||
"dev": true
|
||||
},
|
||||
"mime-types": {
|
||||
"version": "2.1.19",
|
||||
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.19.tgz",
|
||||
"integrity": "sha512-P1tKYHVSZ6uFo26mtnve4HQFE3koh1UWVkp8YUC+ESBHe945xWSoXuHHiGarDqcEZ+whpCDnlNw5LON0kLo+sw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"mime-db": "~1.35.0"
|
||||
}
|
||||
},
|
||||
"minimatch": {
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
|
||||
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
},
|
||||
"minimist": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
|
||||
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=",
|
||||
"dev": true
|
||||
},
|
||||
"mkdirp": {
|
||||
"version": "0.5.1",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
|
||||
"integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"minimist": "0.0.8"
|
||||
},
|
||||
"dependencies": {
|
||||
"minimist": {
|
||||
"version": "0.0.8",
|
||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
|
||||
"integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"nan": {
|
||||
"version": "2.10.0",
|
||||
"resolved": "https://registry.npmjs.org/nan/-/nan-2.10.0.tgz",
|
||||
"integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA==",
|
||||
"dev": true
|
||||
},
|
||||
"once": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||
"integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
},
|
||||
"path-is-absolute": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
|
||||
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
|
||||
"dev": true
|
||||
},
|
||||
"pathval": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz",
|
||||
"integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=",
|
||||
"dev": true
|
||||
},
|
||||
"pify": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
|
||||
"integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=",
|
||||
"dev": true
|
||||
},
|
||||
"pretty-bytes": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-4.0.2.tgz",
|
||||
"integrity": "sha1-sr+C5zUNZcbDOqlaqlpPYyf2HNk=",
|
||||
"dev": true
|
||||
},
|
||||
"process-nextick-args": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz",
|
||||
"integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==",
|
||||
"dev": true
|
||||
},
|
||||
"readable-stream": {
|
||||
"version": "2.3.6",
|
||||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
|
||||
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"core-util-is": "~1.0.0",
|
||||
"inherits": "~2.0.3",
|
||||
"isarray": "~1.0.0",
|
||||
"process-nextick-args": "~2.0.0",
|
||||
"safe-buffer": "~5.1.1",
|
||||
"string_decoder": "~1.1.1",
|
||||
"util-deprecate": "~1.0.1"
|
||||
}
|
||||
},
|
||||
"remove-trailing-separator": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz",
|
||||
"integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=",
|
||||
"dev": true
|
||||
},
|
||||
"replace-ext": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-1.0.0.tgz",
|
||||
"integrity": "sha1-3mMSg3P8v3w8z6TeWkgMRaZ5WOs=",
|
||||
"dev": true
|
||||
},
|
||||
"safe-buffer": {
|
||||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
|
||||
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==",
|
||||
"dev": true
|
||||
},
|
||||
"smartchai": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/smartchai/-/smartchai-2.0.1.tgz",
|
||||
"integrity": "sha512-9M+R56OhAHXScxgr2vzQqxGx0XMS0QXriNZuP7hjlbVbo2FUT+l60iEzbwPt9Ga+5u2cEEjSSoZEQVqlROaddA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/chai": "^4.1.2",
|
||||
"@types/chai-as-promised": "^7.1.0",
|
||||
"@types/chai-string": "^1.4.0",
|
||||
"chai": "^4.1.2",
|
||||
"chai-as-promised": "^7.1.1",
|
||||
"chai-string": "^1.4.0"
|
||||
}
|
||||
},
|
||||
"source-map": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
|
||||
"dev": true
|
||||
},
|
||||
"source-map-support": {
|
||||
"version": "0.5.8",
|
||||
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.8.tgz",
|
||||
"integrity": "sha512-WqAEWPdb78u25RfKzOF0swBpY0dKrNdjc4GvLwm7ScX/o9bj8Eh/YL8mcMhBHYDGl87UkkSXDOFnW4G7GhWhGg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"buffer-from": "^1.0.0",
|
||||
"source-map": "^0.6.0"
|
||||
}
|
||||
},
|
||||
"sprintf-js": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
|
||||
"integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=",
|
||||
"dev": true
|
||||
},
|
||||
"string_decoder": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
|
||||
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"safe-buffer": "~5.1.0"
|
||||
}
|
||||
},
|
||||
"strip-bom": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz",
|
||||
"integrity": "sha1-YhmoVhZSBJHzV4i9vxRHqZx+aw4=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"is-utf8": "^0.2.0"
|
||||
}
|
||||
},
|
||||
"strip-bom-buf": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/strip-bom-buf/-/strip-bom-buf-1.0.0.tgz",
|
||||
"integrity": "sha1-HLRar1dTD0yvhsf3UXnSyaUd1XI=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"is-utf8": "^0.2.1"
|
||||
}
|
||||
},
|
||||
"strip-bom-stream": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/strip-bom-stream/-/strip-bom-stream-2.0.0.tgz",
|
||||
"integrity": "sha1-+H217yYT9paKpUWr/h7HKLaoKco=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"first-chunk-stream": "^2.0.0",
|
||||
"strip-bom": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"ts-node": {
|
||||
"version": "7.0.1",
|
||||
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-7.0.1.tgz",
|
||||
"integrity": "sha512-BVwVbPJRspzNh2yfslyT1PSbl5uIk03EZlb493RKHN4qej/D06n1cEhjlOJG69oFsE7OT8XjpTUcYf6pKTLMhw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"arrify": "^1.0.0",
|
||||
"buffer-from": "^1.1.0",
|
||||
"diff": "^3.1.0",
|
||||
"make-error": "^1.1.1",
|
||||
"minimist": "^1.2.0",
|
||||
"mkdirp": "^0.5.1",
|
||||
"source-map-support": "^0.5.6",
|
||||
"yn": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"type-detect": {
|
||||
"version": "4.0.8",
|
||||
"resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz",
|
||||
"integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==",
|
||||
"dev": true
|
||||
},
|
||||
"typescript": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.0.1.tgz",
|
||||
"integrity": "sha512-zQIMOmC+372pC/CCVLqnQ0zSBiY7HHodU7mpQdjiZddek4GMj31I3dUJ7gAs9o65X7mnRma6OokOkc6f9jjfBg==",
|
||||
"dev": true
|
||||
},
|
||||
"universalify": {
|
||||
"version": "0.1.2",
|
||||
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz",
|
||||
"integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==",
|
||||
"dev": true
|
||||
},
|
||||
"util-deprecate": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
|
||||
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=",
|
||||
"dev": true
|
||||
},
|
||||
"vinyl": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/vinyl/-/vinyl-2.2.0.tgz",
|
||||
"integrity": "sha512-MBH+yP0kC/GQ5GwBqrTPTzEfiiLjta7hTtvQtbxBgTeSXsmKQRQecjibMbxIXzVT3Y9KJK+drOz1/k+vsu8Nkg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"clone": "^2.1.1",
|
||||
"clone-buffer": "^1.0.0",
|
||||
"clone-stats": "^1.0.0",
|
||||
"cloneable-readable": "^1.0.0",
|
||||
"remove-trailing-separator": "^1.0.1",
|
||||
"replace-ext": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"vinyl-file": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/vinyl-file/-/vinyl-file-3.0.0.tgz",
|
||||
"integrity": "sha1-sQTZ5ECf+jJfqt1SBkLQo7SIs2U=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"graceful-fs": "^4.1.2",
|
||||
"pify": "^2.3.0",
|
||||
"strip-bom-buf": "^1.0.0",
|
||||
"strip-bom-stream": "^2.0.0",
|
||||
"vinyl": "^2.0.1"
|
||||
}
|
||||
},
|
||||
"which": {
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz",
|
||||
"integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"isexe": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"wrappy": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
|
||||
"dev": true
|
||||
},
|
||||
"yn": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/yn/-/yn-2.0.0.tgz",
|
||||
"integrity": "sha1-5a2ryKz0CPY4X8dklWhMiOavaJo=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
}
|
||||
71
package.json
71
package.json
@@ -1,26 +1,69 @@
|
||||
{
|
||||
"name": "@pushrocks/smartfuzzy",
|
||||
"version": "1.1.0",
|
||||
"name": "@push.rocks/smartfuzzy",
|
||||
"version": "2.0.0",
|
||||
"private": false,
|
||||
"description": "fuzzy match strings against word dictionaries/arrays",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"description": "A library for fuzzy matching strings against word dictionaries or arrays, with support for object and article searching.",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"author": "Lossless GmbH",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"test": "(tstest test/)",
|
||||
"format": "(gitzone format)",
|
||||
"build": "(tsbuild)"
|
||||
"build": "(tsbuild tsfolders --allowimplicitany)",
|
||||
"buildDocs": "tsdoc"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.0.22",
|
||||
"@gitzone/tstest": "^1.0.15",
|
||||
"@pushrocks/tapbundle": "^3.0.5",
|
||||
"@types/node": "^10.7.1"
|
||||
"@git.zone/tsbuild": "^2.6.4",
|
||||
"@git.zone/tsrun": "^1.3.3",
|
||||
"@git.zone/tstest": "^2.3.2",
|
||||
"@push.rocks/tapbundle": "^6.0.3",
|
||||
"@types/node": "^22.15.17"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/leven": "^2.1.1",
|
||||
"fuse.js": "^3.2.1",
|
||||
"leven": "^2.1.0"
|
||||
}
|
||||
"@push.rocks/smartpromise": "^4.0.2",
|
||||
"@tsclass/tsclass": "^9.2.0",
|
||||
"fuse.js": "^7.1.0",
|
||||
"leven": "^4.0.0"
|
||||
},
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
],
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
"ts_web/**/*",
|
||||
"dist/**/*",
|
||||
"dist_*/**/*",
|
||||
"dist_ts/**/*",
|
||||
"dist_ts_web/**/*",
|
||||
"assets/**/*",
|
||||
"cli.js",
|
||||
"npmextra.json",
|
||||
"readme.md"
|
||||
],
|
||||
"keywords": [
|
||||
"fuzzy matching",
|
||||
"string matching",
|
||||
"dictionary matching",
|
||||
"search",
|
||||
"text analysis",
|
||||
"object sorting",
|
||||
"article search",
|
||||
"text similarity",
|
||||
"keyword matching",
|
||||
"data filtering"
|
||||
],
|
||||
"homepage": "https://code.foss.global/push.rocks/smartfuzzy#readme",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://code.foss.global/push.rocks/smartfuzzy.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://code.foss.global/push.rocks/smartfuzzy/issues"
|
||||
},
|
||||
"type": "module",
|
||||
"pnpm": {
|
||||
"overrides": {}
|
||||
},
|
||||
"packageManager": "pnpm@10.10.0+sha512.d615db246fe70f25dcfea6d8d73dee782ce23e2245e3c4f6f888249fb568149318637dca73c2c5c8ef2a4ca0d5657fb9567188bfab47f566d1ee6ce987815c39"
|
||||
}
|
||||
|
||||
10892
pnpm-lock.yaml
generated
Normal file
10892
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
1
readme.hints.md
Normal file
1
readme.hints.md
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
651
readme.md
Normal file
651
readme.md
Normal file
@@ -0,0 +1,651 @@
|
||||
# @push.rocks/smartfuzzy 🧠✨
|
||||
|
||||
> **Smart fuzzy matching for the modern developer** - Effortlessly match strings, sort objects, and search content with intelligent algorithms
|
||||
|
||||
A powerful TypeScript library that brings intelligent fuzzy matching to your applications. Whether you're building search features, autocomplete functionality, or data filtering systems, SmartFuzzy delivers the precision and flexibility you need.
|
||||
|
||||
## 🚀 Features
|
||||
|
||||
- **🎯 Precise String Matching** - Find closest matches in dictionaries with confidence scores
|
||||
- **📊 Smart Object Sorting** - Sort objects by property similarity with customizable criteria
|
||||
- **📄 Advanced Article Search** - Multi-field content search with intelligent weighting
|
||||
- **⚡ Lightning Fast** - Built on proven algorithms (Levenshtein distance + Fuse.js)
|
||||
- **🔧 TypeScript Native** - Full type safety and IntelliSense support
|
||||
- **📱 Universal** - Works in Node.js and modern browsers
|
||||
|
||||
## 📦 Installation
|
||||
|
||||
Install using pnpm (recommended):
|
||||
|
||||
```bash
|
||||
pnpm install @push.rocks/smartfuzzy
|
||||
```
|
||||
|
||||
Or with your preferred package manager:
|
||||
```bash
|
||||
npm install @push.rocks/smartfuzzy
|
||||
# or
|
||||
yarn add @push.rocks/smartfuzzy
|
||||
```
|
||||
|
||||
## 🌐 Browser Compatibility
|
||||
|
||||
SmartFuzzy works in all modern environments:
|
||||
|
||||
### Node.js
|
||||
- **Node.js 16+** (ES2022 support required)
|
||||
- Full TypeScript support with type definitions included
|
||||
|
||||
### Browsers
|
||||
- **Modern browsers** supporting ES2022 features
|
||||
- Chrome 94+, Firefox 93+, Safari 15+, Edge 94+
|
||||
- **No additional build setup required** - works with standard bundlers
|
||||
|
||||
### TypeScript Setup
|
||||
Ensure your `tsconfig.json` includes:
|
||||
```json
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"esModuleInterop": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Bundle Size
|
||||
- **Core library**: ~15KB minified + gzipped
|
||||
- **Dependencies**: Fuse.js (~12KB), Leven (~2KB)
|
||||
- **Total footprint**: ~29KB minified + gzipped
|
||||
|
||||
## 🚀 Quick Start (30 seconds)
|
||||
|
||||
Get up and running with SmartFuzzy in under a minute:
|
||||
|
||||
```typescript
|
||||
import { Smartfuzzy } from '@push.rocks/smartfuzzy';
|
||||
|
||||
// 1. Create a fuzzy matcher
|
||||
const fuzzy = new Smartfuzzy(['apple', 'banana', 'orange']);
|
||||
|
||||
// 2. Find the best match
|
||||
const match = fuzzy.findClosestMatch('aple'); // Returns: 'apple'
|
||||
|
||||
// 3. That's it! 🎉
|
||||
```
|
||||
|
||||
**Need object searching?** Use `ObjectSorter`:
|
||||
```typescript
|
||||
import { ObjectSorter } from '@push.rocks/smartfuzzy';
|
||||
|
||||
const products = [{ name: 'iPhone' }, { name: 'Android' }];
|
||||
const sorter = new ObjectSorter(products);
|
||||
const results = sorter.sort('iphone', ['name']);
|
||||
```
|
||||
|
||||
## 💻 Usage
|
||||
|
||||
SmartFuzzy is designed for developers who need intelligent matching without the complexity. Jump right in with these real-world examples!
|
||||
|
||||
### 🎯 Quick Start
|
||||
|
||||
```typescript
|
||||
import { Smartfuzzy, ObjectSorter, ArticleSearch } from '@push.rocks/smartfuzzy';
|
||||
```
|
||||
|
||||
### 🔍 Smart String Matching
|
||||
|
||||
Perfect for autocomplete, spell-check, or finding the best match from a list:
|
||||
|
||||
```typescript
|
||||
const myDictionary = ['Sony', 'Deutsche Bahn', 'Apple Inc.', "Trader Joe's"];
|
||||
const mySmartFuzzy = new Smartfuzzy(myDictionary);
|
||||
|
||||
// Adding additional dictionary entries
|
||||
mySmartFuzzy.addToDictionary('Microsoft');
|
||||
mySmartFuzzy.addToDictionary(['Google', 'Facebook']);
|
||||
|
||||
// Finding the closest match
|
||||
const searchResult = mySmartFuzzy.findClosestMatch('Appl');
|
||||
console.log(searchResult); // Output: "Apple Inc."
|
||||
|
||||
// Calculate similarity scores for all dictionary entries
|
||||
const scores = mySmartFuzzy.calculateScores('Appl');
|
||||
console.log(scores);
|
||||
// Output: { 'Sony': 4, 'Deutsche Bahn': 11, 'Apple Inc.': 5, ... }
|
||||
// Lower scores indicate better matches
|
||||
```
|
||||
|
||||
This example demonstrates how to instantiate the `Smartfuzzy` class with a list of strings (dictionary) and add more entries to it. You can then use it to find the closest match or calculate similarity scores for a given search string.
|
||||
|
||||
|
||||
|
||||
### 📊 Intelligent Object Sorting
|
||||
|
||||
Transform any object array into a smart, searchable dataset:
|
||||
|
||||
```typescript
|
||||
interface ICar {
|
||||
brand: string;
|
||||
model: string;
|
||||
}
|
||||
|
||||
const carList: ICar[] = [
|
||||
{ brand: 'BMW', model: 'M3' },
|
||||
{ brand: 'Mercedes Benz', model: 'E-Class' },
|
||||
{ brand: 'Volvo', model: 'XC90' },
|
||||
];
|
||||
|
||||
const carSorter = new ObjectSorter<ICar>(carList);
|
||||
|
||||
// Search and sort based on brand similarity
|
||||
const searchResults = carSorter.sort('Benz', ['brand']);
|
||||
console.log(searchResults); // Results will be sorted by relevance to 'Benz'
|
||||
```
|
||||
|
||||
This scenario shows how to use `ObjectSorter` for sorting an array of objects based on how closely one of their string properties matches a search term. This is particularly useful for filtering or autocomplete features where relevance is key.
|
||||
|
||||
### 📄 Powerful Content Search
|
||||
|
||||
Build sophisticated search experiences for articles, blog posts, or any content with multiple fields:
|
||||
|
||||
```typescript
|
||||
import { IArticle } from '@tsclass/tsclass/content';
|
||||
|
||||
const articles: IArticle[] = [
|
||||
{
|
||||
title: 'History of Berlin',
|
||||
content: 'Berlin has a rich history...',
|
||||
tags: ['history', 'Berlin'],
|
||||
timestamp: Date.now(),
|
||||
featuredImageUrl: null,
|
||||
url: null,
|
||||
},
|
||||
{
|
||||
title: 'Tourism in Berlin',
|
||||
content: 'Discover the vibrant city of Berlin...',
|
||||
tags: ['travel', 'Berlin'],
|
||||
timestamp: Date.now(),
|
||||
featuredImageUrl: null,
|
||||
url: null,
|
||||
},
|
||||
];
|
||||
|
||||
const articleSearch = new ArticleSearch(articles);
|
||||
|
||||
// Perform a search across titles, content, and tags
|
||||
const searchResult = await articleSearch.search('rich history');
|
||||
console.log(searchResult); // Array of matches with relevance to 'rich history'
|
||||
```
|
||||
|
||||
The `ArticleSearch` class showcases how to implement a search feature across a collection of articles with prioritization across different fields (e.g., title, content, tags). This ensures more relevant search results and creates a better experience for users navigating through large datasets or content libraries.
|
||||
|
||||
## 🔥 Real-World Use Cases
|
||||
|
||||
### Search-as-You-Type
|
||||
Build responsive search experiences:
|
||||
|
||||
```typescript
|
||||
import { Smartfuzzy } from '@push.rocks/smartfuzzy';
|
||||
|
||||
const cities = ['New York', 'Los Angeles', 'Chicago', 'Houston', 'Phoenix'];
|
||||
const citySearch = new Smartfuzzy(cities);
|
||||
|
||||
// User types "new yo"
|
||||
const suggestions = citySearch.calculateScores('new yo');
|
||||
// Returns: { 'New York': 2, 'Los Angeles': 8, ... }
|
||||
|
||||
// Show top 3 suggestions
|
||||
const topSuggestions = Object.entries(suggestions)
|
||||
.sort(([,a], [,b]) => a - b)
|
||||
.slice(0, 3)
|
||||
.map(([city]) => city);
|
||||
```
|
||||
|
||||
### Data Deduplication
|
||||
Clean up messy datasets:
|
||||
|
||||
```typescript
|
||||
import { ObjectSorter } from '@push.rocks/smartfuzzy';
|
||||
|
||||
const contacts = [
|
||||
{ name: 'John Smith', email: 'john@example.com' },
|
||||
{ name: 'Jon Smith', email: 'jon.smith@example.com' }, // Likely duplicate
|
||||
{ name: 'Jane Doe', email: 'jane@example.com' }
|
||||
];
|
||||
|
||||
const sorter = new ObjectSorter(contacts);
|
||||
|
||||
// Find potential duplicates for each contact
|
||||
contacts.forEach(contact => {
|
||||
const matches = sorter.sort(contact.name, ['name']);
|
||||
if (matches.length > 1 && matches[0].score < 0.3) {
|
||||
console.log(`Potential duplicate: ${contact.name} ↔ ${matches[1].item.name}`);
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### Smart Product Search
|
||||
E-commerce search with typo tolerance:
|
||||
|
||||
```typescript
|
||||
import { ObjectSorter } from '@push.rocks/smartfuzzy';
|
||||
|
||||
const products = [
|
||||
{ name: 'iPhone 15 Pro', category: 'Electronics', brand: 'Apple' },
|
||||
{ name: 'MacBook Air', category: 'Computers', brand: 'Apple' },
|
||||
{ name: 'AirPods Pro', category: 'Audio', brand: 'Apple' }
|
||||
];
|
||||
|
||||
const productSearch = new ObjectSorter(products);
|
||||
|
||||
// User searches "macbok air" (with typos)
|
||||
const results = productSearch.sort('macbok air', ['name', 'brand']);
|
||||
// Correctly finds "MacBook Air" despite typos
|
||||
```
|
||||
|
||||
### Recommendation System
|
||||
Content-based recommendations:
|
||||
|
||||
```typescript
|
||||
import { ArticleSearch } from '@push.rocks/smartfuzzy';
|
||||
|
||||
const articles = [
|
||||
{ title: 'React Hooks Guide', tags: ['react', 'javascript'], content: '...' },
|
||||
{ title: 'Vue.js Tutorial', tags: ['vue', 'javascript'], content: '...' },
|
||||
{ title: 'Angular Components', tags: ['angular', 'typescript'], content: '...' }
|
||||
];
|
||||
|
||||
const articleSearch = new ArticleSearch(articles);
|
||||
|
||||
// User reads about React, find similar content
|
||||
const similar = await articleSearch.search('react javascript hooks');
|
||||
// Returns articles ordered by relevance
|
||||
```
|
||||
|
||||
## 🚨 Error Handling
|
||||
|
||||
SmartFuzzy provides clear error messages and graceful degradation:
|
||||
|
||||
### Input Validation
|
||||
```typescript
|
||||
import { Smartfuzzy } from '@push.rocks/smartfuzzy';
|
||||
|
||||
const fuzzy = new Smartfuzzy(['apple', 'banana']);
|
||||
|
||||
try {
|
||||
// ❌ This will throw an error
|
||||
const result = fuzzy.findClosestMatch(123 as any);
|
||||
} catch (error) {
|
||||
console.error('Error:', error.message); // "Input must be a string"
|
||||
}
|
||||
```
|
||||
|
||||
### Graceful Degradation
|
||||
```typescript
|
||||
// Empty dictionary returns null instead of throwing
|
||||
const emptyFuzzy = new Smartfuzzy([]);
|
||||
const result = emptyFuzzy.findClosestMatch('test'); // Returns: null
|
||||
|
||||
// Empty object array returns empty results
|
||||
const emptyObjectSorter = new ObjectSorter([]);
|
||||
const results = emptyObjectSorter.sort('test', ['name']); // Returns: []
|
||||
```
|
||||
|
||||
### Best Practices
|
||||
```typescript
|
||||
import { Smartfuzzy, ObjectSorter } from '@push.rocks/smartfuzzy';
|
||||
|
||||
// ✅ Always validate your inputs
|
||||
function safeSearch(query: unknown, dictionary: string[]) {
|
||||
if (typeof query !== 'string') {
|
||||
return null; // Or throw a custom error
|
||||
}
|
||||
|
||||
if (!Array.isArray(dictionary) || dictionary.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const fuzzy = new Smartfuzzy(dictionary);
|
||||
return fuzzy.findClosestMatch(query);
|
||||
}
|
||||
|
||||
// ✅ Handle async operations properly
|
||||
async function searchArticles(query: string, articles: IArticle[]) {
|
||||
try {
|
||||
const search = new ArticleSearch(articles);
|
||||
const results = await search.search(query);
|
||||
return results;
|
||||
} catch (error) {
|
||||
console.error('Search failed:', error);
|
||||
return []; // Return empty results on error
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 📋 API Reference
|
||||
|
||||
### Smartfuzzy Class
|
||||
|
||||
The core fuzzy matching class for string dictionaries.
|
||||
|
||||
#### Constructor
|
||||
```typescript
|
||||
new Smartfuzzy(dictionary?: string[])
|
||||
```
|
||||
- **dictionary** (optional): Array of strings to search against
|
||||
|
||||
#### Methods
|
||||
|
||||
##### `findClosestMatch(searchString: string): string | null`
|
||||
Find the best matching string from the dictionary.
|
||||
- **searchString**: String to find a match for
|
||||
- **Returns**: Best match or `null` if no match found
|
||||
- **Throws**: Error if input is not a string
|
||||
|
||||
##### `calculateScores(searchString: string): TDictionaryMap`
|
||||
Calculate similarity scores for all dictionary entries.
|
||||
- **searchString**: String to score against
|
||||
- **Returns**: Object mapping dictionary words to their scores (lower = better)
|
||||
|
||||
##### `addToDictionary(items: string | string[]): void`
|
||||
Add new entries to the search dictionary.
|
||||
- **items**: Single string or array of strings to add
|
||||
|
||||
---
|
||||
|
||||
### ObjectSorter\<T\> Class
|
||||
|
||||
Generic object sorting with fuzzy matching on specified properties.
|
||||
|
||||
#### Constructor
|
||||
```typescript
|
||||
new ObjectSorter<T>(objects?: T[])
|
||||
```
|
||||
- **objects** (optional): Array of objects to search within
|
||||
|
||||
#### Methods
|
||||
|
||||
##### `sort(searchString: string, keys: string[]): IFuzzySearchResult<T>[]`
|
||||
Sort objects by property similarity to search string.
|
||||
- **searchString**: String to match against object properties
|
||||
- **keys**: Array of object property names to search within
|
||||
- **Returns**: Array of matches sorted by relevance
|
||||
- **Throws**: Error for invalid inputs
|
||||
|
||||
##### `IFuzzySearchResult<T>` Interface
|
||||
```typescript
|
||||
interface IFuzzySearchResult<T> {
|
||||
item: T; // The matched object
|
||||
refIndex: number; // Original array index
|
||||
score?: number; // Match score (lower = better)
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### ArticleSearch Class
|
||||
|
||||
Specialized search for article content with intelligent field weighting.
|
||||
|
||||
#### Constructor
|
||||
```typescript
|
||||
new ArticleSearch(articles?: IArticle[])
|
||||
```
|
||||
- **articles** (optional): Array of articles to search
|
||||
|
||||
#### Methods
|
||||
|
||||
##### `search(searchString: string): Promise<IArticleSearchResult[]>`
|
||||
Perform weighted search across article fields.
|
||||
- **searchString**: Query to search for
|
||||
- **Returns**: Promise resolving to array of matched articles
|
||||
- **Field Weights**: Title (3x), Tags (2x), Content (1x)
|
||||
|
||||
##### `addArticle(article: IArticle): void`
|
||||
Add a single article to the search collection.
|
||||
- **article**: Article object to add
|
||||
|
||||
##### `IArticleSearchResult` Interface
|
||||
```typescript
|
||||
interface IArticleSearchResult {
|
||||
item: IArticle; // The matched article
|
||||
refIndex: number; // Original array index
|
||||
score?: number; // Match score
|
||||
matches?: Array<{ // Match details
|
||||
indices: Array<[number, number]>;
|
||||
key?: string;
|
||||
value?: string;
|
||||
}>;
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## ⚡ Performance Guide
|
||||
|
||||
### Time Complexity
|
||||
- **Smartfuzzy.findClosestMatch**: O(n × m) where n = dictionary size, m = average string length
|
||||
- **ObjectSorter.sort**: O(n × k × m) where k = number of keys to search
|
||||
- **ArticleSearch.search**: O(n × f × m) where f = number of fields (title, content, tags)
|
||||
|
||||
### Recommended Dataset Sizes
|
||||
- **Small (< 1,000 items)**: Excellent performance, sub-millisecond responses
|
||||
- **Medium (1,000 - 10,000 items)**: Good performance, 1-10ms responses
|
||||
- **Large (10,000+ items)**: Consider chunking or server-side search for real-time UIs
|
||||
|
||||
### Optimization Tips
|
||||
|
||||
#### 1. Reuse Instances
|
||||
```typescript
|
||||
// ✅ Good: Reuse the same instance
|
||||
const fuzzy = new Smartfuzzy(largeDictionary);
|
||||
const result1 = fuzzy.findClosestMatch('query1');
|
||||
const result2 = fuzzy.findClosestMatch('query2');
|
||||
|
||||
// ❌ Avoid: Creating new instances repeatedly
|
||||
const result1 = new Smartfuzzy(largeDictionary).findClosestMatch('query1');
|
||||
const result2 = new Smartfuzzy(largeDictionary).findClosestMatch('query2');
|
||||
```
|
||||
|
||||
#### 2. Batch Operations
|
||||
```typescript
|
||||
// ✅ Good: Calculate scores once, extract multiple matches
|
||||
const scores = fuzzy.calculateScores('query');
|
||||
const topMatches = Object.entries(scores)
|
||||
.sort(([,a], [,b]) => a - b)
|
||||
.slice(0, 5);
|
||||
|
||||
// ❌ Avoid: Multiple separate lookups
|
||||
const match1 = fuzzy.findClosestMatch('query');
|
||||
const match2 = fuzzy.findClosestMatch('query'); // Duplicate work
|
||||
```
|
||||
|
||||
#### 3. Optimize Search Keys
|
||||
```typescript
|
||||
// ✅ Good: Search only necessary fields
|
||||
const results = sorter.sort('query', ['name']); // Fast
|
||||
|
||||
// ❌ Avoid: Searching unnecessary fields
|
||||
const results = sorter.sort('query', ['name', 'description', 'notes']); // Slower
|
||||
```
|
||||
|
||||
#### 4. Memory Management
|
||||
```typescript
|
||||
// For very large datasets, consider chunking
|
||||
function chunkedSearch(query: string, largeArray: any[], chunkSize = 1000) {
|
||||
const results = [];
|
||||
|
||||
for (let i = 0; i < largeArray.length; i += chunkSize) {
|
||||
const chunk = largeArray.slice(i, i + chunkSize);
|
||||
const sorter = new ObjectSorter(chunk);
|
||||
results.push(...sorter.sort(query, ['name']));
|
||||
}
|
||||
|
||||
return results.sort((a, b) => a.score - b.score);
|
||||
}
|
||||
```
|
||||
|
||||
### Advanced Configuration
|
||||
|
||||
#### Custom Fuse.js Options
|
||||
|
||||
**Current Implementation**: The Fuse.js options are optimized for general use cases:
|
||||
|
||||
```typescript
|
||||
// Default configuration in SmartFuzzy
|
||||
const fuseOptions = {
|
||||
shouldSort: true,
|
||||
threshold: 0.6, // 0.0 = exact match, 1.0 = match anything
|
||||
location: 0, // Start position for search
|
||||
distance: 100, // Search distance from location
|
||||
maxPatternLength: 32, // Maximum pattern length
|
||||
minMatchCharLength: 1 // Minimum match character length
|
||||
};
|
||||
```
|
||||
|
||||
**Configuration Guidelines**:
|
||||
- **threshold: 0.0-1.0** - Lower values require closer matches
|
||||
- **distance** - How far from `location` to search
|
||||
- **location** - Where in the string to start searching (0 = beginning)
|
||||
|
||||
#### Custom Matching Behavior
|
||||
|
||||
While direct configuration isn't exposed yet, you can achieve custom behavior:
|
||||
|
||||
```typescript
|
||||
// For stricter matching, filter results by score
|
||||
const fuzzy = new Smartfuzzy(['apple', 'application', 'apply']);
|
||||
const scores = fuzzy.calculateScores('app');
|
||||
|
||||
// Only accept very close matches (score < 2)
|
||||
const strictMatches = Object.entries(scores)
|
||||
.filter(([word, score]) => score < 2)
|
||||
.sort(([,a], [,b]) => a - b);
|
||||
|
||||
// For more lenient matching, use a higher threshold in your logic
|
||||
const lenientMatches = Object.entries(scores)
|
||||
.filter(([word, score]) => score < 5)
|
||||
.sort(([,a], [,b]) => a - b);
|
||||
```
|
||||
|
||||
#### Article Search Weighting
|
||||
The ArticleSearch class uses intelligent field weighting:
|
||||
|
||||
```typescript
|
||||
// Built-in weighting (not directly configurable)
|
||||
const searchWeights = {
|
||||
title: 3, // Highest priority - titles are most important
|
||||
tags: 2, // Medium priority - tags are descriptive
|
||||
content: 1 // Lower priority - content can be lengthy
|
||||
};
|
||||
|
||||
// This means a match in the title has 3x more relevance than content
|
||||
```
|
||||
|
||||
|
||||
## 🎉 Why Choose SmartFuzzy?
|
||||
|
||||
- **🧠 Intelligent**: Uses proven algorithms for accurate matching
|
||||
- **⚡ Fast**: Optimized for performance in real-world applications
|
||||
- **🔧 Flexible**: Adapts to your specific use cases and data structures
|
||||
- **🛡️ Reliable**: Comprehensive test coverage and TypeScript safety
|
||||
- **📚 Well-Documented**: Clear examples and complete API documentation
|
||||
|
||||
## 🔍 Troubleshooting & FAQ
|
||||
|
||||
### Common Issues
|
||||
|
||||
#### "Cannot find module" errors
|
||||
```bash
|
||||
# Ensure you've installed the package
|
||||
pnpm install @push.rocks/smartfuzzy
|
||||
|
||||
# For TypeScript projects, types are included automatically
|
||||
```
|
||||
|
||||
#### Poor matching results
|
||||
```typescript
|
||||
// If matches seem inaccurate, check your input data
|
||||
const fuzzy = new Smartfuzzy(['apple', 'APPLE', 'Apple']);
|
||||
// Consider normalizing case before adding to dictionary
|
||||
const normalizedDict = ['apple', 'banana', 'orange'].map(s => s.toLowerCase());
|
||||
const fuzzy2 = new Smartfuzzy(normalizedDict);
|
||||
```
|
||||
|
||||
#### Performance issues with large datasets
|
||||
```typescript
|
||||
// For > 10,000 items, consider limiting search scope
|
||||
const scores = fuzzy.calculateScores('query');
|
||||
const topResults = Object.entries(scores)
|
||||
.sort(([,a], [,b]) => a - b)
|
||||
.slice(0, 10); // Only get top 10 results
|
||||
```
|
||||
|
||||
### FAQ
|
||||
|
||||
**Q: Can I search case-insensitively?**
|
||||
A: SmartFuzzy is case-sensitive by default. Normalize your data:
|
||||
```typescript
|
||||
const fuzzy = new Smartfuzzy(dict.map(s => s.toLowerCase()));
|
||||
const result = fuzzy.findClosestMatch(query.toLowerCase());
|
||||
```
|
||||
|
||||
**Q: How do I handle special characters?**
|
||||
A: Fuse.js handles Unicode well, but you may want to normalize:
|
||||
```typescript
|
||||
const normalize = (str: string) => str.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
|
||||
```
|
||||
|
||||
**Q: Can I weight object properties differently?**
|
||||
A: Currently not directly configurable, but you can post-process results:
|
||||
```typescript
|
||||
const results = sorter.sort(query, ['name', 'description']);
|
||||
// Boost results that matched 'name' field
|
||||
const boosted = results.map(r => ({
|
||||
...r,
|
||||
score: r.matches?.some(m => m.key === 'name') ? r.score * 0.5 : r.score
|
||||
}));
|
||||
```
|
||||
|
||||
**Q: What's the difference between `findClosestMatch` and `calculateScores`?**
|
||||
A: `findClosestMatch` returns only the best match, while `calculateScores` returns scores for all dictionary entries, letting you implement custom ranking logic.
|
||||
|
||||
**Q: How do I handle empty results?**
|
||||
A: Always check for null/empty returns:
|
||||
```typescript
|
||||
const match = fuzzy.findClosestMatch('query');
|
||||
if (match === null) {
|
||||
console.log('No suitable match found');
|
||||
}
|
||||
```
|
||||
|
||||
## 🚀 Get Started Today
|
||||
|
||||
Ready to add intelligent search to your application? SmartFuzzy makes it easy:
|
||||
|
||||
1. Install the package
|
||||
2. Import the classes you need
|
||||
3. Start matching, sorting, and searching!
|
||||
|
||||
Perfect for building search bars, recommendation systems, data filters, and more.
|
||||
|
||||
## License and Legal Information
|
||||
|
||||
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
|
||||
|
||||
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
||||
|
||||
### Trademarks
|
||||
|
||||
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
|
||||
|
||||
### Company Information
|
||||
|
||||
Task Venture Capital GmbH
|
||||
Registered at District court Bremen HRB 35230 HB, Germany
|
||||
|
||||
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
||||
|
||||
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
||||
172
readme.plan.md
Normal file
172
readme.plan.md
Normal file
@@ -0,0 +1,172 @@
|
||||
# SmartFuzzy Improvement Plan - Fuse.js Optimization Focus
|
||||
|
||||
## Current Status
|
||||
- ESM imports/exports fixed with .js extensions
|
||||
- Basic fuzzy matching functionality works
|
||||
- Testing infrastructure fixed with @git.zone/tsrun dependency
|
||||
- Test syntax standardized using SmartExpect syntax
|
||||
- Tests improved with proper assertions and error handling
|
||||
- Input validation added to all public methods
|
||||
- Code documented with comprehensive TypeScript JSDoc comments
|
||||
- Method names standardized for better API consistency
|
||||
- Backward compatibility maintained through deprecated method aliases
|
||||
|
||||
## Improvement Plan - Fuse.js Optimization Focus
|
||||
|
||||
### 1. Fully Leverage Fuse.js Capabilities
|
||||
|
||||
#### 1.1 Enhance Configurability
|
||||
- [ ] Create a comprehensive `FuzzyOptions` interface exposing Fuse.js options
|
||||
- **Implementation approach**:
|
||||
- Expose all relevant Fuse.js options (threshold, distance, location, etc.)
|
||||
- Group options logically (matching control, performance control, output control)
|
||||
- Add proper TypeScript types and documentation for each option
|
||||
- Create sensible defaults for different use cases (loose matching, exact matching, etc.)
|
||||
- Add option validation with clear error messages
|
||||
- Implement runtime option updates via setOptions() method
|
||||
|
||||
#### 1.2 Improve Weighted Field Support
|
||||
- [ ] Enhance ObjectSorter to support field weights like ArticleSearch
|
||||
- **Implementation approach**:
|
||||
- Add ability to specify weight per field in ObjectSorter
|
||||
- Maintain backward compatibility with current simple array of fields
|
||||
- Create examples of different weighting strategies
|
||||
- Add tests demonstrating the effect of different field weights
|
||||
- Include weight settings in all relevant documentation
|
||||
|
||||
#### 1.3 Add Extended Search Capabilities
|
||||
- [ ] Implement Fuse.js extended search syntax support
|
||||
- **Implementation approach**:
|
||||
- Add support for Fuse.js extended search syntax (AND, OR, exact matching)
|
||||
- Create helper methods to build complex search queries
|
||||
- Add examples of extended search usage in documentation
|
||||
- Create tests for complex search patterns
|
||||
- Implement query validation for extended search syntax
|
||||
|
||||
### 2. Performance Optimization
|
||||
|
||||
#### 2.1 Optimize Index Creation
|
||||
- [ ] Implement proper Fuse.js index management
|
||||
- **Implementation approach**:
|
||||
- Create persistent indices instead of rebuilding for each search
|
||||
- Add incremental index updates when items are added/removed
|
||||
- Implement proper index serialization and deserialization
|
||||
- Add option to lazily rebuild indices
|
||||
- Create tests measuring index creation performance
|
||||
|
||||
#### 2.2 Implement Basic Caching
|
||||
- [ ] Add results caching for repeated queries
|
||||
- **Implementation approach**:
|
||||
- Implement simple Map-based cache for query results
|
||||
- Add cache invalidation on dictionary/object changes
|
||||
- Create configurable cache size limits
|
||||
- Add cache hit/miss tracking for debugging
|
||||
- Implement optional cache persistence
|
||||
|
||||
#### 2.3 Add Async Processing for Large Datasets
|
||||
- [ ] Implement non-blocking search operations for large datasets
|
||||
- **Implementation approach**:
|
||||
- Create async versions of search methods that don't block main thread
|
||||
- Implement chunked processing for large dictionaries
|
||||
- Add progress tracking for long operations
|
||||
- Create cancellable search operations
|
||||
- Add proper promise handling and error propagation
|
||||
- Measure performance difference between sync and async methods
|
||||
|
||||
### 3. API Improvements
|
||||
|
||||
#### 3.1 Standardize Method Naming
|
||||
- [x] Standardize all method names for consistency
|
||||
- **Implementation completed**:
|
||||
- Renamed `getClosestMatchForString` to `findClosestMatch`
|
||||
- Renamed `getChangeScoreForString` to `calculateScores`
|
||||
- Created backward compatibility aliases with @deprecated tags
|
||||
- Updated all tests with new method names
|
||||
- ✓ Tests pass and build succeeds
|
||||
|
||||
#### 3.2 Add Chainable API
|
||||
- [ ] Create a more fluent API for complex searches
|
||||
- **Implementation approach**:
|
||||
- Implement chainable methods for setting options
|
||||
- Add result transformation methods (map, filter, sort)
|
||||
- Create fluent search building interface
|
||||
- Implement method chaining for filters and transformations
|
||||
- Add proper TypeScript type inference for chainable methods
|
||||
- Create examples demonstrating the chainable API
|
||||
|
||||
#### 3.3 Enhance Return Types
|
||||
- [ ] Improve result objects with more useful information
|
||||
- **Implementation approach**:
|
||||
- Standardize return types across all search methods
|
||||
- Add richer match information (character positions, context)
|
||||
- Implement highlighting helpers for match visualization
|
||||
- Add metadata to search results (time taken, options used)
|
||||
- Create proper TypeScript interfaces for all result types
|
||||
|
||||
### 4. Documentation and Examples
|
||||
|
||||
#### 4.1 Create Comprehensive Documentation
|
||||
- [ ] Improve documentation with Fuse.js-specific information
|
||||
- **Implementation approach**:
|
||||
- Generate TypeDoc documentation from JSDoc comments
|
||||
- Create specific sections for Fuse.js integration details
|
||||
- Add visual diagrams showing how Fuse.js is utilized
|
||||
- Document all configuration options with examples
|
||||
- Add performance guidelines based on Fuse.js recommendations
|
||||
|
||||
#### 4.2 Create Usage Examples
|
||||
- [ ] Add specialized examples for common search patterns
|
||||
- **Implementation approach**:
|
||||
- Create examples for typical search scenarios (autocomplete, filtering, etc.)
|
||||
- Add examples of weighted searching for different use cases
|
||||
- Demonstrate extended search syntax with examples
|
||||
- Create comparative examples showing different configuration effects
|
||||
- Add performance optimization examples
|
||||
|
||||
### 5. Testing Enhancements
|
||||
|
||||
#### 5.1 Add Fuse.js-specific Tests
|
||||
- [ ] Create tests focused on Fuse.js features
|
||||
- **Implementation approach**:
|
||||
- Add tests for all Fuse.js configuration options
|
||||
- Create performance comparison tests for different settings
|
||||
- Implement tests for extended search syntax
|
||||
- Add tests for very large datasets
|
||||
- Create index persistence and rebuilding tests
|
||||
|
||||
#### 5.2 Add Edge Case Tests
|
||||
- [ ] Improve test coverage for Fuse.js edge cases
|
||||
- **Implementation approach**:
|
||||
- Test with unusual strings (very long, special characters, etc.)
|
||||
- Add tests for multilingual content
|
||||
- Create tests for zero-match and all-match cases
|
||||
- Implement tests for threshold boundary conditions
|
||||
- Add tests for unusual scoring scenarios
|
||||
|
||||
## Implementation Priority
|
||||
|
||||
### Phase 1: Core Improvements (1-2 weeks)
|
||||
- [x] API Improvements (3.1 Standardize Method Naming) ✓ COMPLETED
|
||||
- [ ] Configurability Enhancements (1.1 Enhance Configurability)
|
||||
- [ ] Documentation Updates (4.1 Create Comprehensive Documentation)
|
||||
|
||||
### Phase 2: Performance Optimizations (1-2 weeks)
|
||||
- [ ] Optimize Index Creation (2.1)
|
||||
- [ ] Implement Basic Caching (2.2)
|
||||
- [ ] Add Fuse.js-specific Tests (5.1)
|
||||
|
||||
### Phase 3: Advanced Features (2-3 weeks)
|
||||
- [ ] Improve Weighted Field Support (1.2)
|
||||
- [ ] Add Extended Search Capabilities (1.3)
|
||||
- [ ] Add Chainable API (3.2)
|
||||
- [ ] Enhance Return Types (3.3)
|
||||
- [ ] Add Async Processing for Large Datasets (2.3)
|
||||
- [ ] Create Usage Examples (4.2)
|
||||
- [ ] Add Edge Case Tests (5.2)
|
||||
|
||||
## Expected Outcomes
|
||||
- Significantly improved performance for large datasets
|
||||
- More flexible and powerful search capabilities
|
||||
- Better developer experience with improved API design
|
||||
- Clearer understanding of the library through better documentation
|
||||
- Higher test coverage, particularly for edge cases and performance scenarios
|
||||
131
test/test.articlesearch.ts
Normal file
131
test/test.articlesearch.ts
Normal file
@@ -0,0 +1,131 @@
|
||||
import { expect, tap } from '@push.rocks/tapbundle';
|
||||
import * as tsclass from '@tsclass/tsclass';
|
||||
import * as smartfuzzy from '../ts/index.js';
|
||||
|
||||
// Create fixed timestamps for consistent test results
|
||||
const timestamp1 = 1620000000000; // May 2021
|
||||
const timestamp2 = 1620086400000; // May 2021 + 1 day
|
||||
|
||||
// Test articles with known content
|
||||
const testArticles: tsclass.content.IArticle[] = [
|
||||
{
|
||||
title: 'Berlin has a ambivalent history',
|
||||
content: 'it is known that Berlin has an interesting history',
|
||||
author: null,
|
||||
tags: ['city', 'Europe', 'history', 'travel'],
|
||||
timestamp: timestamp1,
|
||||
featuredImageUrl: null,
|
||||
url: null,
|
||||
},
|
||||
{
|
||||
title: 'Washington is a great city',
|
||||
content: 'it is known that Washington is one of the greatest cities in the world',
|
||||
author: null,
|
||||
tags: ['city', 'USA', 'travel', 'politics'],
|
||||
timestamp: timestamp2,
|
||||
featuredImageUrl: null,
|
||||
url: null,
|
||||
},
|
||||
{
|
||||
title: 'Travel tips for European cities',
|
||||
content: 'Here are some travel tips for European cities including Berlin and Paris',
|
||||
author: null,
|
||||
tags: ['travel', 'Europe', 'tips'],
|
||||
timestamp: timestamp2,
|
||||
featuredImageUrl: null,
|
||||
url: null,
|
||||
}
|
||||
];
|
||||
|
||||
let articleSearch: smartfuzzy.ArticleSearch;
|
||||
|
||||
tap.test('should create an ArticleSearch instance', async () => {
|
||||
// Test creation with constructor
|
||||
articleSearch = new smartfuzzy.ArticleSearch(testArticles);
|
||||
expect(articleSearch).toBeInstanceOf(smartfuzzy.ArticleSearch);
|
||||
expect(articleSearch.articles.length).toEqual(testArticles.length);
|
||||
|
||||
// Test empty constructor
|
||||
const emptySearch = new smartfuzzy.ArticleSearch();
|
||||
expect(emptySearch.articles).toBeArray();
|
||||
expect(emptySearch.articles.length).toEqual(0);
|
||||
});
|
||||
|
||||
tap.test('should search by exact tag match', async () => {
|
||||
const result = await articleSearch.search('USA');
|
||||
|
||||
// Should have results
|
||||
expect(result).toBeArray();
|
||||
expect(result.length).toBeGreaterThan(0);
|
||||
|
||||
// First result should be the Washington article (contains USA tag)
|
||||
expect(result[0].item.title).toInclude('Washington');
|
||||
|
||||
// Should include match information
|
||||
expect(result[0].matches).toBeDefined();
|
||||
expect(result[0].matches.length).toBeGreaterThan(0);
|
||||
|
||||
// At least one match should be for the 'USA' tag
|
||||
const tagMatch = result[0].matches.find(m => m.key === 'tags' && m.value === 'USA');
|
||||
expect(tagMatch).toBeDefined();
|
||||
});
|
||||
|
||||
tap.test('should search by title and content', async () => {
|
||||
// Search for term in the title and content of one article
|
||||
const result = await articleSearch.search('Berlin');
|
||||
|
||||
expect(result.length).toBeGreaterThan(0);
|
||||
expect(result[0].item.title).toInclude('Berlin');
|
||||
|
||||
// The Travel article mentions Berlin in content, so it should be included
|
||||
// but ranked lower
|
||||
const berlinArticleIndex = result.findIndex(r => r.item.title.includes('Berlin'));
|
||||
const travelArticleIndex = result.findIndex(r => r.item.title.includes('Travel'));
|
||||
|
||||
expect(berlinArticleIndex).toBeLessThan(travelArticleIndex);
|
||||
});
|
||||
|
||||
tap.test('should add articles incrementally', async () => {
|
||||
const newSearch = new smartfuzzy.ArticleSearch();
|
||||
expect(newSearch.articles.length).toEqual(0);
|
||||
|
||||
// Add one article
|
||||
const newArticle: tsclass.content.IArticle = {
|
||||
title: 'New Article',
|
||||
content: 'This is a new article about technology',
|
||||
author: null,
|
||||
tags: ['technology', 'new'],
|
||||
timestamp: Date.now(),
|
||||
featuredImageUrl: null,
|
||||
url: null,
|
||||
};
|
||||
|
||||
newSearch.addArticle(newArticle);
|
||||
expect(newSearch.articles.length).toEqual(1);
|
||||
expect(newSearch.needsUpdate).toBeTrue();
|
||||
|
||||
// Search should update the index
|
||||
const result = await newSearch.search('technology');
|
||||
expect(result.length).toEqual(1);
|
||||
expect(newSearch.needsUpdate).toBeFalse();
|
||||
|
||||
// Add another article and check if updates work
|
||||
const anotherArticle: tsclass.content.IArticle = {
|
||||
title: 'Another Tech Article',
|
||||
content: 'Another article about technology innovations',
|
||||
author: null,
|
||||
tags: ['technology', 'innovation'],
|
||||
timestamp: Date.now(),
|
||||
featuredImageUrl: null,
|
||||
url: null,
|
||||
};
|
||||
|
||||
newSearch.addArticle(anotherArticle);
|
||||
expect(newSearch.needsUpdate).toBeTrue();
|
||||
|
||||
// Search again should now return both articles
|
||||
const newResult = await newSearch.search('technology');
|
||||
expect(newResult.length).toEqual(2);
|
||||
});
|
||||
|
||||
export default tap.start();
|
||||
86
test/test.objectsorter.ts
Normal file
86
test/test.objectsorter.ts
Normal file
@@ -0,0 +1,86 @@
|
||||
import { expect, tap } from '@push.rocks/tapbundle';
|
||||
import * as smartfuzzy from '../ts/index.js';
|
||||
|
||||
class Car {
|
||||
constructor(public brand: string, public model?: string, public year?: number) {}
|
||||
}
|
||||
|
||||
const testCars = [
|
||||
new Car('BMW', 'X5', 2022),
|
||||
new Car('Mercedes Benz', 'S-Class', 2021),
|
||||
new Car('Volvo', 'XC90', 2023),
|
||||
new Car('Volkswagen', 'Golf', 2020),
|
||||
new Car('Audi', 'A4', 2022),
|
||||
];
|
||||
|
||||
let objectSorter: smartfuzzy.ObjectSorter<Car>;
|
||||
|
||||
tap.test('should create an instance of ObjectSorter', async () => {
|
||||
objectSorter = new smartfuzzy.ObjectSorter<Car>(testCars);
|
||||
expect(objectSorter).toBeInstanceOf(smartfuzzy.ObjectSorter);
|
||||
expect(objectSorter.objectDictionary).toEqual(testCars);
|
||||
|
||||
// Test empty constructor
|
||||
const emptyObjectSorter = new smartfuzzy.ObjectSorter<Car>();
|
||||
expect(emptyObjectSorter.objectDictionary).toEqual([]);
|
||||
});
|
||||
|
||||
tap.test('should sort objects by exact brand match', async () => {
|
||||
const result = objectSorter.sort('Volvo', ['brand']);
|
||||
|
||||
// Should return an array of results
|
||||
expect(result).toBeArray();
|
||||
expect(result.length).toBeGreaterThan(0);
|
||||
|
||||
// First result should be the Volvo
|
||||
expect(result[0].item.brand).toEqual('Volvo');
|
||||
|
||||
// Should have expected result structure
|
||||
expect(result[0]).toHaveProperty('item');
|
||||
expect(result[0]).toHaveProperty('refIndex');
|
||||
expect(result[0].refIndex).toBeTypeofNumber();
|
||||
|
||||
// Reference index should match the original array position
|
||||
expect(result[0].refIndex).toEqual(2); // Volvo is at index 2
|
||||
});
|
||||
|
||||
tap.test('should sort objects by fuzzy brand match', async () => {
|
||||
// "Wolvo" should fuzzy match to "Volvo"
|
||||
const result = objectSorter.sort('Wolvo', ['brand']);
|
||||
|
||||
expect(result.length).toBeGreaterThan(0);
|
||||
expect(result[0].item.brand).toEqual('Volvo');
|
||||
});
|
||||
|
||||
tap.test('should sort objects by multiple field search', async () => {
|
||||
// Add a car with similar model name but different brand
|
||||
objectSorter = new smartfuzzy.ObjectSorter<Car>([
|
||||
...testCars,
|
||||
new Car('Toyota', 'X5 Replica', 2020),
|
||||
]);
|
||||
|
||||
// Search across both brand and model
|
||||
const result = objectSorter.sort('BMW X5', ['brand', 'model']);
|
||||
|
||||
expect(result.length).toBeGreaterThan(0);
|
||||
|
||||
// BMW X5 should be first result
|
||||
expect(result[0].item.brand).toEqual('BMW');
|
||||
expect(result[0].item.model).toEqual('X5');
|
||||
|
||||
// Toyota X5 Replica may be in results depending on threshold
|
||||
// But we shouldn't expect it specifically since results depend on the
|
||||
// fuzzy matching algorithm's threshold setting
|
||||
|
||||
// BMW should be the first result
|
||||
const bmwIndex = result.findIndex(r => r.item.brand === 'BMW');
|
||||
expect(bmwIndex).toEqual(0);
|
||||
|
||||
// If Toyota is in results, it should be ranked lower than BMW
|
||||
const toyotaIndex = result.findIndex(r => r.item.brand === 'Toyota');
|
||||
if (toyotaIndex !== -1) {
|
||||
expect(bmwIndex).toBeLessThan(toyotaIndex);
|
||||
}
|
||||
});
|
||||
|
||||
export default tap.start();
|
||||
69
test/test.smartfuzzy.ts
Normal file
69
test/test.smartfuzzy.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
import { expect, tap } from '@push.rocks/tapbundle';
|
||||
import * as smartfuzzy from '../ts/index.js';
|
||||
|
||||
let testSmartfuzzy: smartfuzzy.Smartfuzzy;
|
||||
const testDictionary = [
|
||||
'Sony',
|
||||
'Deutsche Bahn',
|
||||
'Apple Inc.',
|
||||
"Trader Joe's",
|
||||
];
|
||||
|
||||
tap.test('should create an instance of Smartfuzzy', async () => {
|
||||
testSmartfuzzy = new smartfuzzy.Smartfuzzy(testDictionary);
|
||||
expect(testSmartfuzzy).toBeInstanceOf(smartfuzzy.Smartfuzzy);
|
||||
expect(testSmartfuzzy.dictionary).toEqual(testDictionary);
|
||||
});
|
||||
|
||||
tap.test('should compute a score for a string against the dictionary', async () => {
|
||||
const result = testSmartfuzzy.calculateScores('Apple');
|
||||
|
||||
// Check that we got a dictionary map back
|
||||
expect(result).toBeTypeOf('object');
|
||||
|
||||
// Check that every dictionary entry has a score
|
||||
for (const word of testDictionary) {
|
||||
expect(result).toHaveProperty(word);
|
||||
expect(result[word]).toBeTypeofNumber();
|
||||
}
|
||||
|
||||
// Check that 'Apple Inc.' has a lower score (better match) for 'Apple' than other entries
|
||||
// The leven distance for 'Apple Inc.' from 'Apple' should be less than that of other entries
|
||||
// We can't predict exact values but we can compare them
|
||||
expect(result['Apple Inc.']).toBeLessThanOrEqual(result['Sony']);
|
||||
});
|
||||
|
||||
tap.test('should get closest match for a string', async () => {
|
||||
const result = testSmartfuzzy.findClosestMatch('Apple');
|
||||
|
||||
// Should return closest match as string
|
||||
expect(result).toBeTypeofString();
|
||||
|
||||
// Should match the expected closest entry
|
||||
expect(result).toEqual('Apple Inc.');
|
||||
});
|
||||
|
||||
tap.test('should add words to dictionary', async () => {
|
||||
const initialLength = testSmartfuzzy.dictionary.length;
|
||||
|
||||
// Add a single word
|
||||
testSmartfuzzy.addToDictionary('Microsoft');
|
||||
expect(testSmartfuzzy.dictionary.length).toEqual(initialLength + 1);
|
||||
expect(testSmartfuzzy.dictionary).toContain('Microsoft');
|
||||
|
||||
// Add multiple words
|
||||
const additionalWords = ['Google', 'Amazon', 'Facebook'];
|
||||
testSmartfuzzy.addToDictionary(additionalWords);
|
||||
expect(testSmartfuzzy.dictionary.length).toEqual(initialLength + 4);
|
||||
for (const word of additionalWords) {
|
||||
expect(testSmartfuzzy.dictionary).toContain(word);
|
||||
}
|
||||
});
|
||||
|
||||
tap.test('should handle empty query string', async () => {
|
||||
const result = testSmartfuzzy.findClosestMatch('');
|
||||
// For empty strings, behavior should be defined (either null or a specific result)
|
||||
expect(result).toBeNullOrUndefined();
|
||||
});
|
||||
|
||||
export default tap.start();
|
||||
43
test/test.ts
43
test/test.ts
@@ -1,43 +0,0 @@
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
import * as smartfuzzy from '../ts/index';
|
||||
|
||||
let testSmartfuzzy: smartfuzzy.Smartfuzzy;
|
||||
|
||||
tap.test('should create an instance of Smartfuzzy', async () => {
|
||||
testSmartfuzzy = new smartfuzzy.Smartfuzzy([
|
||||
'Sony',
|
||||
'Deutsche Bahn',
|
||||
'Apple Inc.',
|
||||
"Trader Joe's"
|
||||
]);
|
||||
expect(testSmartfuzzy).to.be.instanceof(smartfuzzy.Smartfuzzy);
|
||||
});
|
||||
|
||||
tap.test('should compute a score', async () => {
|
||||
const result = testSmartfuzzy.getChangeScoreForString('Apple');
|
||||
console.log(result);
|
||||
});
|
||||
|
||||
tap.test('should get closest match', async () => {
|
||||
const result = testSmartfuzzy.getClosestMatchForString('Apple');
|
||||
console.log(result);
|
||||
});
|
||||
|
||||
tap.test('should sort objects', async () => {
|
||||
class Car {
|
||||
constructor(public brand: string) {}
|
||||
}
|
||||
|
||||
let testObjectSorter: smartfuzzy.ObjectSorter<Car>;
|
||||
|
||||
testObjectSorter = new smartfuzzy.ObjectSorter([
|
||||
new Car('BMW'),
|
||||
new Car('Mercedes Benz'),
|
||||
new Car('Volvo')
|
||||
]);
|
||||
|
||||
const result = testObjectSorter.sort('Volvo', ['brand']);
|
||||
console.log(result);
|
||||
});
|
||||
|
||||
tap.start();
|
||||
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @push.rocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@push.rocks/smartfuzzy',
|
||||
version: '1.1.10',
|
||||
description: 'A library for fuzzy matching strings against word dictionaries or arrays, with support for object and article searching.'
|
||||
}
|
||||
@@ -1,2 +1,3 @@
|
||||
export * from './smartfuzzy.classes.smartfuzzy';
|
||||
export * from './smartfuzzy.classes.objectsorter';
|
||||
export * from './smartfuzzy.articlesearch.js';
|
||||
export * from './smartfuzzy.classes.smartfuzzy.js';
|
||||
export * from './smartfuzzy.classes.objectsorter.js';
|
||||
|
||||
205
ts/smartfuzzy.articlesearch.ts
Normal file
205
ts/smartfuzzy.articlesearch.ts
Normal file
@@ -0,0 +1,205 @@
|
||||
import * as plugins from './smartfuzzy.plugins.js';
|
||||
|
||||
/**
|
||||
* Type for the search result returned by ArticleSearch
|
||||
*/
|
||||
export type IArticleSearchResult = {
|
||||
/** The matched article */
|
||||
item: plugins.tsclass.content.IArticle;
|
||||
|
||||
/** The index of the article in the original array */
|
||||
refIndex: number;
|
||||
|
||||
/** The match score (lower is better) */
|
||||
score?: number;
|
||||
|
||||
/** Information about where matches were found in the article */
|
||||
matches?: ReadonlyArray<{
|
||||
indices: ReadonlyArray<readonly [number, number]>;
|
||||
key?: string;
|
||||
value?: string;
|
||||
refIndex?: number;
|
||||
}>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specialized search engine for articles with weighted field searching
|
||||
*
|
||||
* This class provides fuzzy searching against article content, with different weights
|
||||
* assigned to different parts of the article (title, tags, content) to provide
|
||||
* more relevant results.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const articles = [
|
||||
* {
|
||||
* title: 'Getting Started with TypeScript',
|
||||
* content: 'TypeScript is a superset of JavaScript that adds static typing...',
|
||||
* tags: ['typescript', 'javascript', 'programming'],
|
||||
* author: 'John Doe',
|
||||
* timestamp: Date.now(),
|
||||
* featuredImageUrl: null,
|
||||
* url: 'https://example.com/typescript-intro'
|
||||
* }
|
||||
* ];
|
||||
*
|
||||
* const articleSearch = new ArticleSearch(articles);
|
||||
* const results = await articleSearch.search('typescript');
|
||||
* ```
|
||||
*/
|
||||
export class ArticleSearch {
|
||||
/**
|
||||
* Collection of articles to search through
|
||||
*/
|
||||
public articles: plugins.tsclass.content.IArticle[] = [];
|
||||
|
||||
/**
|
||||
* Flag indicating whether the search index needs to be updated
|
||||
*/
|
||||
public needsUpdate: boolean = false;
|
||||
|
||||
/**
|
||||
* Promise manager for async operations
|
||||
*/
|
||||
private readyDeferred = plugins.smartpromise.defer();
|
||||
|
||||
/**
|
||||
* Fuse.js instance for searching
|
||||
*/
|
||||
private fuse: plugins.fuseJs<plugins.tsclass.content.IArticle>;
|
||||
|
||||
/**
|
||||
* Creates a new ArticleSearch instance
|
||||
*
|
||||
* @param articleArrayArg - Optional array of articles to initialize with
|
||||
*/
|
||||
constructor(articleArrayArg?: plugins.tsclass.content.IArticle[]) {
|
||||
// Validate input if provided
|
||||
if (articleArrayArg !== undefined && !Array.isArray(articleArrayArg)) {
|
||||
throw new Error('Article array must be an array');
|
||||
}
|
||||
|
||||
this.fuse = new plugins.fuseJs(this.articles);
|
||||
this.readyDeferred.resolve();
|
||||
|
||||
if (articleArrayArg) {
|
||||
for (const article of articleArrayArg) {
|
||||
// Validate each article has required fields
|
||||
if (!article || typeof article !== 'object') {
|
||||
throw new Error('Each article must be a valid object');
|
||||
}
|
||||
|
||||
// Require at least title field
|
||||
if (!article.title || typeof article.title !== 'string') {
|
||||
throw new Error('Each article must have a title string');
|
||||
}
|
||||
|
||||
this.addArticle(article);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an article to the collection and marks the index for updating
|
||||
*
|
||||
* @param articleArg - The article to add to the search collection
|
||||
* @returns void
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* articleSearch.addArticle({
|
||||
* title: 'Advanced TypeScript Features',
|
||||
* content: 'This article covers advanced TypeScript concepts...',
|
||||
* tags: ['typescript', 'advanced'],
|
||||
* author: 'Jane Smith',
|
||||
* timestamp: Date.now(),
|
||||
* featuredImageUrl: null,
|
||||
* url: 'https://example.com/advanced-typescript'
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
public addArticle(articleArg: plugins.tsclass.content.IArticle): void {
|
||||
if (!articleArg || typeof articleArg !== 'object') {
|
||||
throw new Error('Article must be a valid object');
|
||||
}
|
||||
|
||||
// Require at least title field
|
||||
if (!articleArg.title || typeof articleArg.title !== 'string') {
|
||||
throw new Error('Article must have a title string');
|
||||
}
|
||||
|
||||
// Validate tags if present
|
||||
if (articleArg.tags !== undefined && !Array.isArray(articleArg.tags)) {
|
||||
throw new Error('Article tags must be an array of strings');
|
||||
}
|
||||
|
||||
this.articles.push(articleArg);
|
||||
this.needsUpdate = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a weighted fuzzy search across all articles
|
||||
*
|
||||
* The search uses the following weighting:
|
||||
* - Title: 3x importance
|
||||
* - Tags: 2x importance
|
||||
* - Content: 1x importance
|
||||
*
|
||||
* @param searchStringArg - The search query string
|
||||
* @returns Array of articles matched with their relevance score and match details
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* // Search for articles about TypeScript
|
||||
* const results = await articleSearch.search('typescript');
|
||||
*
|
||||
* // Access the first (most relevant) result
|
||||
* if (results.length > 0) {
|
||||
* console.log(results[0].item.title);
|
||||
*
|
||||
* // See where the match was found
|
||||
* console.log(results[0].matches);
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
public async search(searchStringArg: string): Promise<IArticleSearchResult[]> {
|
||||
if (typeof searchStringArg !== 'string') {
|
||||
throw new Error('Search string must be a string');
|
||||
}
|
||||
|
||||
// Empty article collection should return empty results
|
||||
if (this.articles.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (this.needsUpdate) {
|
||||
const oldDeferred = this.readyDeferred;
|
||||
this.readyDeferred = plugins.smartpromise.defer();
|
||||
this.needsUpdate = false;
|
||||
if (oldDeferred.status !== 'fulfilled') {
|
||||
this.readyDeferred.promise.then(oldDeferred.resolve);
|
||||
}
|
||||
this.fuse = new plugins.fuseJs(this.articles, {
|
||||
keys: [
|
||||
{
|
||||
name: 'title',
|
||||
weight: 3,
|
||||
},
|
||||
{
|
||||
name: 'tags',
|
||||
weight: 2,
|
||||
},
|
||||
{
|
||||
name: 'content',
|
||||
weight: 1,
|
||||
},
|
||||
],
|
||||
includeMatches: true,
|
||||
});
|
||||
this.readyDeferred.resolve();
|
||||
} else {
|
||||
await this.readyDeferred.promise;
|
||||
}
|
||||
return this.fuse.search(searchStringArg);
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,113 @@
|
||||
import * as plugins from './smartfuzzy.plugins';
|
||||
import * as plugins from './smartfuzzy.plugins.js';
|
||||
|
||||
/**
|
||||
* Result of a fuzzy search on objects
|
||||
*
|
||||
* @typeParam T - The type of object being searched
|
||||
*/
|
||||
export interface IFuzzySearchResult<T> {
|
||||
/** The matched object */
|
||||
item: T;
|
||||
|
||||
/** The index of the object in the original array */
|
||||
refIndex: number;
|
||||
|
||||
/** The match score (lower is better) */
|
||||
score?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles fuzzy searching and sorting of objects based on their properties
|
||||
*
|
||||
* @typeParam T - The type of objects to search through
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* interface User {
|
||||
* name: string;
|
||||
* email: string;
|
||||
* }
|
||||
*
|
||||
* const users = [
|
||||
* { name: 'John Smith', email: 'john@example.com' },
|
||||
* { name: 'Jane Doe', email: 'jane@example.com' }
|
||||
* ];
|
||||
*
|
||||
* const sorter = new ObjectSorter<User>(users);
|
||||
* const results = sorter.sort('john', ['name', 'email']);
|
||||
* ```
|
||||
*/
|
||||
export class ObjectSorter<T> {
|
||||
/**
|
||||
* The collection of objects to search through
|
||||
*/
|
||||
public objectDictionary: T[];
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new ObjectSorter instance
|
||||
*
|
||||
* @param objectDictionaryArg - Array of objects to search through
|
||||
*/
|
||||
constructor(objectDictionaryArg: T[] = []) {
|
||||
if (objectDictionaryArg !== undefined && !Array.isArray(objectDictionaryArg)) {
|
||||
throw new Error('Object dictionary must be an array');
|
||||
}
|
||||
this.objectDictionary = objectDictionaryArg;
|
||||
}
|
||||
|
||||
sort(stringArg: string, objectKeysArg: string[]): T[] {
|
||||
/**
|
||||
* Searches and sorts objects based on how well they match the search string
|
||||
* in the specified object properties
|
||||
*
|
||||
* @param stringArg - The search query string
|
||||
* @param objectKeysArg - Array of object property names to search within
|
||||
* @returns Array of results sorted by relevance (best matches first)
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* // Search for 'john' in both name and email fields
|
||||
* const results = sorter.sort('john', ['name', 'email']);
|
||||
*
|
||||
* // First result is the best match
|
||||
* console.log(results[0].item.name); // 'John Smith'
|
||||
* ```
|
||||
*/
|
||||
public sort(stringArg: string, objectKeysArg: string[]): Array<IFuzzySearchResult<T>> {
|
||||
if (typeof stringArg !== 'string') {
|
||||
throw new Error('Search string must be a string');
|
||||
}
|
||||
|
||||
if (!Array.isArray(objectKeysArg)) {
|
||||
throw new Error('Object keys must be an array');
|
||||
}
|
||||
|
||||
if (objectKeysArg.length === 0) {
|
||||
throw new Error('At least one object key must be provided for searching');
|
||||
}
|
||||
|
||||
// Verify all keys are strings
|
||||
for (const key of objectKeysArg) {
|
||||
if (typeof key !== 'string') {
|
||||
throw new Error('All object keys must be strings');
|
||||
}
|
||||
}
|
||||
|
||||
// Empty dictionary should return empty results instead of error
|
||||
if (this.objectDictionary.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const fuseOptions = {
|
||||
shouldSort: true,
|
||||
threshold: 0.6,
|
||||
location: 0,
|
||||
distance: 100,
|
||||
threshold: 0.6, // Lower values = more strict matching
|
||||
location: 0, // Where to start searching in the string
|
||||
distance: 100, // How far to search in the string
|
||||
maxPatternLength: 32,
|
||||
minMatchCharLength: 1,
|
||||
keys: objectKeysArg
|
||||
keys: objectKeysArg,
|
||||
};
|
||||
const fuse = new plugins.fuseJs(this.objectDictionary, fuseOptions);
|
||||
const fuse = new plugins.fuseJs<T>(this.objectDictionary, fuseOptions);
|
||||
const result = fuse.search(stringArg);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,32 +1,94 @@
|
||||
import * as plugins from './smartfuzzy.plugins';
|
||||
import * as plugins from './smartfuzzy.plugins.js';
|
||||
|
||||
export let standardExport = 'Hi there! :) This is an exported string';
|
||||
|
||||
/**
|
||||
* Type representing a dictionary of words mapped to their scores
|
||||
* Lower scores typically indicate better matches
|
||||
*/
|
||||
export type TDictionaryMap = { [key: string]: number };
|
||||
|
||||
/**
|
||||
* Main class for fuzzy string matching against a dictionary
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const fuzzy = new Smartfuzzy(['apple', 'banana', 'orange']);
|
||||
* const result = fuzzy.findClosestMatch('aple'); // Returns 'apple'
|
||||
* ```
|
||||
*/
|
||||
export class Smartfuzzy {
|
||||
dictionary: string[];
|
||||
/**
|
||||
* Array of words used for fuzzy matching
|
||||
*/
|
||||
public dictionary: string[];
|
||||
|
||||
/**
|
||||
* Creates a new Smartfuzzy instance
|
||||
*
|
||||
* @param dictionary - Initial array of words to use for matching
|
||||
*/
|
||||
constructor(dictionary: string[]) {
|
||||
if (!Array.isArray(dictionary)) {
|
||||
throw new Error('Dictionary must be an array of strings');
|
||||
}
|
||||
this.dictionary = dictionary;
|
||||
}
|
||||
|
||||
/**
|
||||
* adds words to the dictionary
|
||||
* @param payloadArg
|
||||
* Adds one or more words to the dictionary
|
||||
*
|
||||
* @param payloadArg - A single word or an array of words to add to the dictionary
|
||||
* @returns void
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* fuzzy.addToDictionary('pear');
|
||||
* fuzzy.addToDictionary(['pear', 'grape', 'kiwi']);
|
||||
* ```
|
||||
*/
|
||||
addToDictionary(payloadArg: string | string[]) {
|
||||
public addToDictionary(payloadArg: string | string[]): void {
|
||||
if (payloadArg === undefined || payloadArg === null) {
|
||||
throw new Error('Input cannot be null or undefined');
|
||||
}
|
||||
|
||||
if (Array.isArray(payloadArg)) {
|
||||
// Validate all items in array are strings
|
||||
for (const item of payloadArg) {
|
||||
if (typeof item !== 'string') {
|
||||
throw new Error('All items in array must be strings');
|
||||
}
|
||||
}
|
||||
this.dictionary = this.dictionary.concat(payloadArg);
|
||||
} else {
|
||||
} else if (typeof payloadArg === 'string') {
|
||||
this.dictionary.push(payloadArg);
|
||||
} else {
|
||||
throw new Error('Input must be a string or an array of strings');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the closest match for a given string
|
||||
* @param stringArg
|
||||
* Calculates the Levenshtein distance (edit distance) between the input string
|
||||
* and each word in the dictionary
|
||||
*
|
||||
* @param stringArg - The string to compare against the dictionary
|
||||
* @returns A dictionary map where keys are words and values are edit distances
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const scores = fuzzy.calculateScores('aple');
|
||||
* // Returns: { 'apple': 1, 'banana': 5, 'orange': 5 }
|
||||
* ```
|
||||
*/
|
||||
getChangeScoreForString(stringArg): TDictionaryMap {
|
||||
public calculateScores(stringArg: string): TDictionaryMap {
|
||||
if (typeof stringArg !== 'string') {
|
||||
throw new Error('Input must be a string');
|
||||
}
|
||||
|
||||
if (this.dictionary.length === 0) {
|
||||
throw new Error('Dictionary is empty');
|
||||
}
|
||||
|
||||
const dictionaryMap: TDictionaryMap = {};
|
||||
for (const wordArg of this.dictionary) {
|
||||
dictionaryMap[wordArg] = plugins.leven(stringArg, wordArg);
|
||||
@@ -34,11 +96,32 @@ export class Smartfuzzy {
|
||||
return dictionaryMap;
|
||||
}
|
||||
|
||||
getClosestMatchForString(stringArg: string) {
|
||||
|
||||
/**
|
||||
* Finds the closest matching word in the dictionary using fuzzy search
|
||||
*
|
||||
* @param stringArg - The string to find a match for
|
||||
* @returns The closest matching word, or null if no match is found or dictionary is empty
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const match = fuzzy.findClosestMatch('oragne');
|
||||
* // Returns: 'orange'
|
||||
* ```
|
||||
*/
|
||||
public findClosestMatch(stringArg: string): string | null {
|
||||
if (typeof stringArg !== 'string') {
|
||||
throw new Error('Input must be a string');
|
||||
}
|
||||
|
||||
if (this.dictionary.length === 0) {
|
||||
return null; // Return null for empty dictionary instead of throwing error
|
||||
}
|
||||
|
||||
const fuseDictionary: { name: string }[] = [];
|
||||
for (const wordArg of this.dictionary) {
|
||||
fuseDictionary.push({
|
||||
name: wordArg
|
||||
name: wordArg,
|
||||
});
|
||||
}
|
||||
const fuseOptions = {
|
||||
@@ -48,10 +131,15 @@ export class Smartfuzzy {
|
||||
distance: 100,
|
||||
maxPatternLength: 32,
|
||||
minMatchCharLength: 1,
|
||||
keys: ['name']
|
||||
keys: ['name'],
|
||||
};
|
||||
const fuse = new plugins.fuseJs(fuseDictionary, fuseOptions);
|
||||
const result = fuse.search(stringArg);
|
||||
return result;
|
||||
const fuzzyResult = fuse.search(stringArg);
|
||||
let closestMatch: string = null;
|
||||
if (fuzzyResult.length > 0) {
|
||||
closestMatch = fuzzyResult[0].item.name;
|
||||
}
|
||||
return closestMatch;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,15 @@
|
||||
import leven = require('leven');
|
||||
const fuseJs = require('fuse.js');
|
||||
// @pushrocks scope
|
||||
import * as smartpromise from '@push.rocks/smartpromise';
|
||||
|
||||
export { smartpromise };
|
||||
|
||||
// @tsclass scope
|
||||
import * as tsclass from '@tsclass/tsclass';
|
||||
|
||||
export { tsclass };
|
||||
|
||||
// third party scope
|
||||
import leven from 'leven';
|
||||
import fuseJs from 'fuse.js';
|
||||
|
||||
export { leven, fuseJs };
|
||||
|
||||
16
tsconfig.json
Normal file
16
tsconfig.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true,
|
||||
"baseUrl": ".",
|
||||
"paths": {}
|
||||
},
|
||||
"exclude": [
|
||||
"dist_*/**/*.d.ts"
|
||||
]
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"extends": ["tslint:latest", "tslint-config-prettier"],
|
||||
"rules": {
|
||||
"semicolon": [true, "always"]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user