fix(build): Fix import paths, update CI workflows and upgrade dependencies for ESM compliance
This commit is contained in:
parent
d647706881
commit
4fc2eb6ece
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
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -3,7 +3,6 @@
|
||||
# artifacts
|
||||
coverage/
|
||||
public/
|
||||
pages/
|
||||
|
||||
# installs
|
||||
node_modules/
|
||||
@ -17,4 +16,4 @@ node_modules/
|
||||
dist/
|
||||
dist_*/
|
||||
|
||||
# custom
|
||||
#------# custom
|
138
.gitlab-ci.yml
138
.gitlab-ci.yml
@ -1,138 +0,0 @@
|
||||
# gitzone ci_default
|
||||
image: registry.gitlab.com/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
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
auditProductionDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --production --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high --only=prod --production
|
||||
tags:
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
auditDevDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install --ignore-scripts
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command npm audit --audit-level=high --only=dev
|
||||
tags:
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
# ====================
|
||||
# test stage
|
||||
# ====================
|
||||
|
||||
testStable:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
|
||||
testBuild:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci command npm run build
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci node install stable
|
||||
- npmci npm publish
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
# ====================
|
||||
# metadata stage
|
||||
# ====================
|
||||
codequality:
|
||||
stage: metadata
|
||||
allow_failure: true
|
||||
only:
|
||||
- tags
|
||||
script:
|
||||
- npmci command npm install -g tslint typescript
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- priv
|
||||
|
||||
trigger:
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci trigger
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
pages:
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci node install lts
|
||||
- npmci command npm install -g @gitzone/tsdoc
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command tsdoc
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
only:
|
||||
- tags
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- public
|
||||
allow_failure: true
|
53
changelog.md
Normal file
53
changelog.md
Normal file
@ -0,0 +1,53 @@
|
||||
# Changelog
|
||||
|
||||
## 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
|
25847
package-lock.json
generated
25847
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
31
package.json
31
package.json
@ -10,19 +10,20 @@
|
||||
"scripts": {
|
||||
"test": "(tstest test/)",
|
||||
"format": "(gitzone format)",
|
||||
"build": "(tsbuild)"
|
||||
"build": "(tsbuild)",
|
||||
"buildDocs": "tsdoc"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.27",
|
||||
"@gitzone/tstest": "^1.0.57",
|
||||
"@pushrocks/tapbundle": "^3.2.14",
|
||||
"@types/node": "^16.10.2"
|
||||
"@git.zone/tsbuild": "^2.1.27",
|
||||
"@git.zone/tstest": "^1.0.57",
|
||||
"@push.rocks/tapbundle": "^6.0.3",
|
||||
"@types/node": "^22.15.17"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pushrocks/smartpromise": "^3.1.6",
|
||||
"@tsclass/tsclass": "^3.0.33",
|
||||
"fuse.js": "^6.4.6",
|
||||
"leven": "^3.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"
|
||||
@ -51,9 +52,17 @@
|
||||
"keyword matching",
|
||||
"data filtering"
|
||||
],
|
||||
"homepage": "https://code.foss.global/push.rocks/smartfuzzy",
|
||||
"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"
|
||||
}
|
11884
pnpm-lock.yaml
generated
11884
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
26
readme.md
26
readme.md
@ -19,11 +19,7 @@ npm install @push.rocks/smartfuzzy --save
|
||||
First, ensure you import the necessary components:
|
||||
|
||||
```typescript
|
||||
import {
|
||||
Smartfuzzy,
|
||||
ObjectSorter,
|
||||
ArticleSearch
|
||||
} from '@push.rocks/smartfuzzy';
|
||||
import { Smartfuzzy, ObjectSorter, ArticleSearch } from '@push.rocks/smartfuzzy';
|
||||
```
|
||||
|
||||
### Basic String Matching
|
||||
@ -58,7 +54,7 @@ interface ICar {
|
||||
const carList: ICar[] = [
|
||||
{ brand: 'BMW', model: 'M3' },
|
||||
{ brand: 'Mercedes Benz', model: 'E-Class' },
|
||||
{ brand: 'Volvo', model: 'XC90' }
|
||||
{ brand: 'Volvo', model: 'XC90' },
|
||||
];
|
||||
|
||||
const carSorter = new ObjectSorter<ICar>(carList);
|
||||
@ -78,8 +74,22 @@ If your application involves searching through articles or similar textual conte
|
||||
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 }
|
||||
{
|
||||
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);
|
||||
|
85
readme.plan.md
Normal file
85
readme.plan.md
Normal file
@ -0,0 +1,85 @@
|
||||
# SmartFuzzy Improvement Plan
|
||||
|
||||
## Current Status
|
||||
- ESM imports/exports fixed with .js extensions
|
||||
- Basic fuzzy matching functionality works
|
||||
- Tests run individually with tsx but fail with pnpm test
|
||||
- Using older versions of dependencies
|
||||
|
||||
## Improvement Plan
|
||||
|
||||
### 1. Fix Testing Infrastructure
|
||||
|
||||
#### 1.1 Fix Test Runner Configuration
|
||||
- [ ] Investigate why `pnpm test` fails while individual tests run with `tsx` succeed
|
||||
- [ ] Check if `tsrun` command is properly installed and available (current error shows "tsrun: command not found")
|
||||
- [ ] Examine the `tstest` configuration in package.json and update if needed
|
||||
- [ ] Verify that `@git.zone/tstest` dependency is properly installed and configured
|
||||
- [ ] Consider updating the test script to use `tsx` directly if `tstest` continues to be problematic
|
||||
|
||||
#### 1.2 Update Test Syntax and Standards
|
||||
- [ ] Convert all tests from chai-style syntax (`expect().to.be`) to SmartExpect syntax (`expect().toBeInstanceOf()`)
|
||||
- [ ] Implement consistent test structure across all test files
|
||||
- [ ] Add proper setup and teardown patterns where needed
|
||||
- [ ] Replace console.log statements with proper assertions to validate results
|
||||
- [ ] Add descriptive error messages to assertions to improve test debugging
|
||||
|
||||
#### 1.3 Expand Test Coverage
|
||||
- [ ] Add tests for empty dictionaries and edge cases
|
||||
- [ ] Test with extremely large dictionaries to verify performance
|
||||
- [ ] Add tests for unicode/special character handling
|
||||
- [ ] Test with very similar strings to validate fuzzy matching accuracy
|
||||
- [ ] Add tests for error conditions and input validation
|
||||
- [ ] Implement tests for all public APIs and features
|
||||
|
||||
#### 1.4 Test Automation and CI
|
||||
- [ ] Add test coverage reporting
|
||||
- [ ] Set up continuous integration for automated testing
|
||||
- [ ] Add performance regression tests
|
||||
- [ ] Create test fixtures for consistent test data
|
||||
- [ ] Add browser-based tests for web compatibility
|
||||
|
||||
### 2. Code Quality Improvements
|
||||
- [ ] Add proper TypeScript documentation comments to all public methods
|
||||
- [ ] Implement consistent error handling
|
||||
- [ ] Add input validation for all public methods
|
||||
- [ ] Standardize method naming conventions (e.g., get* vs find*)
|
||||
|
||||
### 3. Feature Enhancements
|
||||
- [ ] Add configurable threshold options for matching
|
||||
- [ ] Implement stemming/lemmatization support for better text matching
|
||||
- [ ] Add language-specific matching options
|
||||
- [ ] Support for weighted matching across multiple fields
|
||||
- [ ] Add batch processing capabilities for large datasets
|
||||
|
||||
### 4. Performance Optimizations
|
||||
- [ ] Implement caching for repeated searches
|
||||
- [ ] Optimize indexing for large dictionaries
|
||||
- [ ] Add benchmarking tests to measure performance improvements
|
||||
|
||||
### 5. Dependencies and Build System
|
||||
- [ ] Update to latest versions of dependencies
|
||||
- [ ] Ensure proper tree-shaking for browser bundle
|
||||
- [ ] Add browser-specific build configuration
|
||||
- [ ] Implement proper ES module / CommonJS dual package setup
|
||||
|
||||
### 6. Documentation
|
||||
- [ ] Create comprehensive API documentation
|
||||
- [ ] Add usage examples for common scenarios
|
||||
- [ ] Create benchmarks comparing to other fuzzy matching libraries
|
||||
- [ ] Document performance characteristics and optimization strategies
|
||||
|
||||
### 7. Developer Experience
|
||||
- [ ] Add VS Code debugging configuration
|
||||
- [ ] Implement changelog generation
|
||||
- [ ] Set up automated release process
|
||||
- [ ] Add contribution guidelines
|
||||
|
||||
## Priority Order
|
||||
1. Fix testing infrastructure (critical)
|
||||
2. Code quality improvements (high)
|
||||
3. Documentation (high)
|
||||
4. Feature enhancements (medium)
|
||||
5. Performance optimizations (medium)
|
||||
6. Dependencies and build system (medium)
|
||||
7. Developer experience (low)
|
@ -1,6 +1,6 @@
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
import { expect, tap } from '@push.rocks/tapbundle';
|
||||
import * as tsclass from '@tsclass/tsclass';
|
||||
import * as smartfuzzy from '../ts/index';
|
||||
import * as smartfuzzy from '../ts/index.js';
|
||||
|
||||
tap.test('should sort objects', async () => {
|
||||
const articleArray: tsclass.content.IArticle[] = [
|
||||
|
@ -1,14 +1,12 @@
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
import * as smartfuzzy from '../ts/index';
|
||||
import { expect, tap } from '@push.rocks/tapbundle';
|
||||
import * as smartfuzzy from '../ts/index.js';
|
||||
|
||||
tap.test('should sort objects', async () => {
|
||||
class Car {
|
||||
constructor(public brand: string) {}
|
||||
}
|
||||
|
||||
let testObjectSorter: smartfuzzy.ObjectSorter<Car>;
|
||||
|
||||
testObjectSorter = new smartfuzzy.ObjectSorter([
|
||||
const testObjectSorter = new smartfuzzy.ObjectSorter<Car>([
|
||||
new Car('BMW'),
|
||||
new Car('Mercedes Benz'),
|
||||
new Car('Volvo'),
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
import * as smartfuzzy from '../ts/index';
|
||||
import { expect, tap } from '@push.rocks/tapbundle';
|
||||
import * as smartfuzzy from '../ts/index.js';
|
||||
|
||||
let testSmartfuzzy: smartfuzzy.Smartfuzzy;
|
||||
|
||||
@ -10,7 +10,7 @@ tap.test('should create an instance of Smartfuzzy', async () => {
|
||||
'Apple Inc.',
|
||||
"Trader Joe's",
|
||||
]);
|
||||
expect(testSmartfuzzy).to.be.instanceof(smartfuzzy.Smartfuzzy);
|
||||
expect(testSmartfuzzy).toBeInstanceOf(smartfuzzy.Smartfuzzy);
|
||||
});
|
||||
|
||||
tap.test('should compute a score', async () => {
|
||||
|
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.7',
|
||||
description: 'A library for fuzzy matching strings against word dictionaries or arrays, with support for object and article searching.'
|
||||
}
|
@ -1,3 +1,3 @@
|
||||
export * from './smartfuzzy.articlesearch';
|
||||
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';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as plugins from './smartfuzzy.plugins';
|
||||
import * as plugins from './smartfuzzy.plugins.js';
|
||||
|
||||
/**
|
||||
* an article search that searches articles in a weighted manner
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as plugins from './smartfuzzy.plugins';
|
||||
import * as plugins from './smartfuzzy.plugins.js';
|
||||
|
||||
export class ObjectSorter<T> {
|
||||
public objectDictionary: T[];
|
||||
@ -7,7 +7,7 @@ export class ObjectSorter<T> {
|
||||
this.objectDictionary = objectDictionaryArg;
|
||||
}
|
||||
|
||||
sort(stringArg: string, objectKeysArg: string[]): plugins.fuseJs.FuseResult<T>[] {
|
||||
sort(stringArg: string, objectKeysArg: string[]): Array<{ item: T; refIndex: number; score?: number }> {
|
||||
const fuseOptions = {
|
||||
shouldSort: true,
|
||||
threshold: 0.6,
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as plugins from './smartfuzzy.plugins';
|
||||
import * as plugins from './smartfuzzy.plugins.js';
|
||||
|
||||
export let standardExport = 'Hi there! :) This is an exported string';
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
// @pushrocks scope
|
||||
import * as smartpromise from '@pushrocks/smartpromise';
|
||||
import * as smartpromise from '@push.rocks/smartpromise';
|
||||
|
||||
export { smartpromise };
|
||||
|
||||
|
@ -6,7 +6,9 @@
|
||||
"module": "NodeNext",
|
||||
"moduleResolution": "NodeNext",
|
||||
"esModuleInterop": true,
|
||||
"verbatimModuleSyntax": true
|
||||
"verbatimModuleSyntax": true,
|
||||
"baseUrl": ".",
|
||||
"paths": {}
|
||||
},
|
||||
"exclude": [
|
||||
"dist_*/**/*.d.ts"
|
||||
|
Loading…
x
Reference in New Issue
Block a user