@bluelovers/string-natural-compare
Advanced tools
Comparing version 2.0.10 to 2.0.11
@@ -6,2 +6,12 @@ # Change Log | ||
## [2.0.11](https://github.com/bluelovers/ws-array/compare/@bluelovers/string-natural-compare@2.0.10...@bluelovers/string-natural-compare@2.0.11) (2022-10-14) | ||
### 📦 Code Refactoring | ||
* update deps ([792099b](https://github.com/bluelovers/ws-array/commit/792099b9f9752522e261d7f89bb1e373f1dc359f)) | ||
## [2.0.10](https://github.com/bluelovers/ws-array/compare/@bluelovers/string-natural-compare@2.0.9...@bluelovers/string-natural-compare@2.0.10) (2022-10-10) | ||
@@ -8,0 +18,0 @@ |
@@ -1,14 +0,3 @@ | ||
/** | ||
* Created by user on 2020/6/4. | ||
*/ | ||
export interface IOptionsStringNaturalCompare { | ||
/** | ||
* Set to true to compare strings case-insensitively. Default: false. | ||
*/ | ||
caseInsensitive?: boolean; | ||
/** | ||
* A string of characters that define a custom character ordering. Default: undefined. | ||
*/ | ||
alphabet?: string; | ||
} | ||
import { IOptions as IOptionsStringNaturalCompare } from 'string-natural-compare2'; | ||
export interface IOptionsNaturalCompare extends IOptionsStringNaturalCompare { | ||
@@ -25,19 +14,14 @@ desc?: boolean; | ||
export declare function naturalCompare(a: string | number, b: string | number, opts?: IOptionsNaturalCompare): number; | ||
export declare namespace naturalCompare { | ||
export var createNew: typeof createNew; | ||
export var compareCaseInsensitive: (a: string | number, b: string | number) => number; | ||
export var caseInsensitive: (a: string | number, b: string | number) => number; | ||
var _a: typeof naturalCompare; | ||
export { _a as default }; | ||
} | ||
export type ICompareFn = (a: string | number, b: string | number) => number; | ||
/** | ||
* create compare with preset options | ||
*/ | ||
export declare function createNew(opts?: IOptionsNaturalCompare): (a: string | number, b: string | number) => number; | ||
export declare function createNew(opts?: IOptionsNaturalCompare): ICompareFn; | ||
/** | ||
* compare strings case-insensitively | ||
*/ | ||
export declare const compareCaseInsensitive: (a: string | number, b: string | number) => number; | ||
export declare const compareCaseInsensitive: ICompareFn; | ||
export { | ||
IOptions as IOptionsStringNaturalCompare, | ||
compareCaseInsensitive as caseInsensitive, | ||
@@ -44,0 +28,0 @@ naturalCompare as default, |
{ | ||
"name": "@bluelovers/string-natural-compare", | ||
"version": "2.0.10", | ||
"version": "2.0.11", | ||
"description": "Compare alphanumeric strings the same way a human would, using a natural order algorithm", | ||
@@ -62,3 +62,3 @@ "keywords": [ | ||
"dependencies": { | ||
"string-natural-compare": "^3.0.1" | ||
"string-natural-compare2": "^3.0.1" | ||
}, | ||
@@ -69,3 +69,3 @@ "packageManager": "yarn@^1.22.11", | ||
}, | ||
"gitHead": "c83428b467812ee10e5e6f72b46ff79a64d763a2" | ||
"gitHead": "7b52de45e7022cc53fa1411f639b598b824b2cdc" | ||
} |
@@ -1,20 +0,5 @@ | ||
/** | ||
* Created by user on 2020/6/4. | ||
*/ | ||
import { naturalCompare as _naturalCompare, IOptions as IOptionsStringNaturalCompare } from 'string-natural-compare2'; | ||
// @ts-ignore | ||
import _naturalCompare from 'string-natural-compare'; | ||
export type { IOptionsStringNaturalCompare } | ||
export interface IOptionsStringNaturalCompare | ||
{ | ||
/** | ||
* Set to true to compare strings case-insensitively. Default: false. | ||
*/ | ||
caseInsensitive?: boolean, | ||
/** | ||
* A string of characters that define a custom character ordering. Default: undefined. | ||
*/ | ||
alphabet?: string, | ||
} | ||
export interface IOptionsNaturalCompare extends IOptionsStringNaturalCompare | ||
@@ -35,5 +20,8 @@ { | ||
let i: number; | ||
const typeA = typeof a === 'number'; | ||
const typeB = typeof b === 'number'; | ||
if (typeof a === 'number' && typeof b === 'number') | ||
if (typeA && typeB) | ||
{ | ||
// @ts-ignore | ||
i = a - b | ||
@@ -43,7 +31,7 @@ } | ||
{ | ||
if (typeof a === 'number') | ||
if (typeA) | ||
{ | ||
a = String(a); | ||
} | ||
else if (typeof b === 'number') | ||
if (typeB) | ||
{ | ||
@@ -58,3 +46,3 @@ b = String(b); | ||
i = _naturalCompare(a, b, opts) | ||
i = _naturalCompare(a as any, b as any, opts) | ||
} | ||
@@ -70,6 +58,8 @@ | ||
export type ICompareFn = (a: string | number, b: string | number) => number; | ||
/** | ||
* create compare with preset options | ||
*/ | ||
export function createNew(opts?: IOptionsNaturalCompare) | ||
export function createNew(opts?: IOptionsNaturalCompare): ICompareFn | ||
{ | ||
@@ -88,9 +78,15 @@ return (a: string | number, b: string | number) => naturalCompare(a, b, opts) | ||
naturalCompare.createNew = createNew; | ||
naturalCompare.compareCaseInsensitive = compareCaseInsensitive; | ||
naturalCompare.caseInsensitive = compareCaseInsensitive; | ||
naturalCompare.default = naturalCompare; | ||
// @ts-ignore | ||
if (process.env.TSDX_FORMAT !== 'esm') | ||
{ | ||
Object.defineProperty(naturalCompare, "__esModule", { value: true }); | ||
Object.defineProperty(naturalCompare, "__esModule", { value: true }); | ||
Object.defineProperty(naturalCompare, "default", { value: naturalCompare }); | ||
Object.defineProperty(naturalCompare, "naturalCompare", { value: naturalCompare }); | ||
Object.defineProperty(naturalCompare, "createNew", { value: createNew }); | ||
Object.defineProperty(naturalCompare, "compareCaseInsensitive", { value: compareCaseInsensitive }); | ||
Object.defineProperty(naturalCompare, "caseInsensitive", { value: compareCaseInsensitive }); | ||
} | ||
export default naturalCompare |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 2 instances in 1 package
37019
17
307
0
+ Addedstring-natural-compare2@3.0.1(transitive)
- Removedstring-natural-compare@^3.0.1
- Removedstring-natural-compare@3.0.1(transitive)