@bluelovers/string-natural-compare
Advanced tools
| /** | ||
| * Created by user on 2020/6/20. | ||
| */ | ||
| import naturalCompare from './index'; | ||
| export = naturalCompare; |
+10
| "use strict"; | ||
| /** | ||
| * Created by user on 2020/6/20. | ||
| */ | ||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||
| return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
| }; | ||
| const index_1 = __importDefault(require("./index")); | ||
| module.exports = index_1.default; | ||
| //# sourceMappingURL=node.js.map |
| {"version":3,"file":"node.js","sourceRoot":"","sources":["node.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,oDAAqC;AAErC,iBAAS,eAAc,CAAA","sourcesContent":["/**\n * Created by user on 2020/6/20.\n */\n\nimport naturalCompare from './index';\n\nexport = naturalCompare\n"]} |
+11
-0
@@ -6,2 +6,13 @@ # Change Log | ||
| ## [1.1.1](https://github.com/bluelovers/ws-array/compare/@bluelovers/string-natural-compare@1.0.7...@bluelovers/string-natural-compare@1.1.1) (2020-06-19) | ||
| ### 🐛 Bug Fixes | ||
| * **typescript:** avoid https://github.com/microsoft/TypeScript/issues/39149 ([44a5863](https://github.com/bluelovers/ws-array/commit/44a586363f01f66ac4d061b71bdefd0a17d4d2b6)) | ||
| ## [1.0.7](https://github.com/bluelovers/ws-array/compare/@bluelovers/string-natural-compare@1.0.6...@bluelovers/string-natural-compare@1.0.7) (2020-06-16) | ||
@@ -8,0 +19,0 @@ |
+2
-38
@@ -1,39 +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; | ||
| } | ||
| export interface IOptionsNaturalCompare extends IOptionsStringNaturalCompare { | ||
| desc?: boolean; | ||
| } | ||
| /** | ||
| * Compare alphanumeric strings the same way a human would, | ||
| * using a natural order algorithm | ||
| * (originally known as the alphanum algorithm) | ||
| * where numeric characters are sorted | ||
| * based on their numeric values rather than their ASCII values. | ||
| */ | ||
| export declare function naturalCompare(a: any, b: any, opts?: IOptionsNaturalCompare): number; | ||
| export declare namespace naturalCompare { | ||
| export var createNew: typeof import("./core").createNew; | ||
| export var compareCaseInsensitive: (a: any, b: any) => number; | ||
| var _a: typeof naturalCompare; | ||
| export { _a as default }; | ||
| } | ||
| /** | ||
| * create compare with preset options | ||
| */ | ||
| export declare function createNew(opts?: IOptionsNaturalCompare): (a: any, b: any) => number; | ||
| /** | ||
| * compare strings case-insensitively | ||
| */ | ||
| export declare const compareCaseInsensitive: (a: any, b: any) => number; | ||
| export * from './index'; | ||
| import naturalCompare from './index'; | ||
| export default naturalCompare; |
+13
-53
| "use strict"; | ||
| /** | ||
| * Created by user on 2020/6/4. | ||
| */ | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
| for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p); | ||
| }; | ||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -9,52 +16,5 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.compareCaseInsensitive = exports.createNew = exports.naturalCompare = void 0; | ||
| const string_natural_compare_1 = __importDefault(require("string-natural-compare")); | ||
| /** | ||
| * Compare alphanumeric strings the same way a human would, | ||
| * using a natural order algorithm | ||
| * (originally known as the alphanum algorithm) | ||
| * where numeric characters are sorted | ||
| * based on their numeric values rather than their ASCII values. | ||
| */ | ||
| function naturalCompare(a, b, opts) { | ||
| let i; | ||
| if (typeof a === 'number' && typeof b === 'number') { | ||
| i = a - b; | ||
| } | ||
| else { | ||
| if (typeof a === 'number') { | ||
| a = String(a); | ||
| } | ||
| else if (typeof b === 'number') { | ||
| b = String(b); | ||
| } | ||
| if (a === b) { | ||
| return 0; | ||
| } | ||
| i = string_natural_compare_1.default(a, b, opts); | ||
| } | ||
| if (i !== 0 && (opts === null || opts === void 0 ? void 0 : opts.desc)) { | ||
| i = 0 - i; | ||
| } | ||
| return i; | ||
| } | ||
| exports.naturalCompare = naturalCompare; | ||
| /** | ||
| * create compare with preset options | ||
| */ | ||
| function createNew(opts) { | ||
| return (a, b) => naturalCompare(a, b, opts); | ||
| } | ||
| exports.createNew = createNew; | ||
| /** | ||
| * compare strings case-insensitively | ||
| */ | ||
| exports.compareCaseInsensitive = createNew({ | ||
| caseInsensitive: true, | ||
| }); | ||
| naturalCompare.createNew = createNew; | ||
| naturalCompare.compareCaseInsensitive = exports.compareCaseInsensitive; | ||
| naturalCompare.default = naturalCompare; | ||
| Object.defineProperty(naturalCompare, "__esModule", { value: true }); | ||
| exports.default = naturalCompare; | ||
| __exportStar(require("./index"), exports); | ||
| const index_1 = __importDefault(require("./index")); | ||
| exports.default = index_1.default; | ||
| //# sourceMappingURL=core.js.map |
+1
-1
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"core.js","sourceRoot":"","sources":["core.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;AAEH,oFAAqD;AAmBrD;;;;;;GAMG;AACH,SAAgB,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,IAA6B;IAEjE,IAAI,CAAS,CAAC;IAEd,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,QAAQ,EAClD;QACC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;KACT;SAED;QACC,IAAI,OAAO,CAAC,KAAK,QAAQ,EACzB;YACC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;SACd;aACI,IAAI,OAAO,CAAC,KAAK,QAAQ,EAC9B;YACC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;SACd;QAED,IAAI,CAAC,KAAK,CAAC,EACX;YACC,OAAO,CAAC,CAAA;SACR;QAED,CAAC,GAAG,gCAAe,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAA;KAC/B;IAED,IAAI,CAAC,KAAK,CAAC,KAAI,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,CAAA,EACzB;QACC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;KACV;IAED,OAAO,CAAC,CAAA;AACT,CAAC;AAjCD,wCAiCC;AAED;;GAEG;AACH,SAAgB,SAAS,CAAC,IAA6B;IAEtD,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAA;AAC5C,CAAC;AAHD,8BAGC;AAED;;GAEG;AACU,QAAA,sBAAsB,GAAG,SAAS,CAAC;IAC/C,eAAe,EAAE,IAAI;CACrB,CAAC,CAAA;AAEF,cAAc,CAAC,SAAS,GAAG,SAAS,CAAC;AACrC,cAAc,CAAC,sBAAsB,GAAG,8BAAsB,CAAC;AAC/D,cAAc,CAAC,OAAO,GAAG,cAAc,CAAC;AAExC,MAAM,CAAC,cAAc,CAAC,cAAc,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAErE,kBAAe,cAAc,CAAA","sourcesContent":["/**\n * Created by user on 2020/6/4.\n */\n\nimport _naturalCompare from 'string-natural-compare';\n\nexport interface IOptionsStringNaturalCompare\n{\n\t/**\n\t * Set to true to compare strings case-insensitively. Default: false.\n\t */\n\tcaseInsensitive?: boolean,\n\t/**\n\t * A string of characters that define a custom character ordering. Default: undefined.\n\t */\n\talphabet?: string,\n}\n\nexport interface IOptionsNaturalCompare extends IOptionsStringNaturalCompare\n{\n\tdesc?: boolean,\n}\n\n/**\n * Compare alphanumeric strings the same way a human would,\n * using a natural order algorithm\n * (originally known as the alphanum algorithm)\n * where numeric characters are sorted\n * based on their numeric values rather than their ASCII values.\n */\nexport function naturalCompare(a, b, opts?: IOptionsNaturalCompare)\n{\n\tlet i: number;\n\n\tif (typeof a === 'number' && typeof b === 'number')\n\t{\n\t\ti = a - b\n\t}\n\telse\n\t{\n\t\tif (typeof a === 'number')\n\t\t{\n\t\t\ta = String(a);\n\t\t}\n\t\telse if (typeof b === 'number')\n\t\t{\n\t\t\tb = String(b);\n\t\t}\n\n\t\tif (a === b)\n\t\t{\n\t\t\treturn 0\n\t\t}\n\n\t\ti = _naturalCompare(a, b, opts)\n\t}\n\n\tif (i !== 0 && opts?.desc)\n\t{\n\t\ti = 0 - i;\n\t}\n\n\treturn i\n}\n\n/**\n * create compare with preset options\n */\nexport function createNew(opts?: IOptionsNaturalCompare)\n{\n\treturn (a, b) => naturalCompare(a, b, opts)\n}\n\n/**\n * compare strings case-insensitively\n */\nexport const compareCaseInsensitive = createNew({\n\tcaseInsensitive: true,\n})\n\nnaturalCompare.createNew = createNew;\nnaturalCompare.compareCaseInsensitive = compareCaseInsensitive;\nnaturalCompare.default = naturalCompare;\n\nObject.defineProperty(naturalCompare, \"__esModule\", { value: true });\n\nexport default naturalCompare\n"]} | ||
| {"version":3,"file":"core.js","sourceRoot":"","sources":["core.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,oDAAqC;AAErC,kBAAe,eAAc,CAAA","sourcesContent":["export * from './index';\nimport naturalCompare from './index';\n\nexport default naturalCompare\n"]} |
+36
-2
| /** | ||
| * Created by user on 2020/6/4. | ||
| */ | ||
| import naturalCompare from './core'; | ||
| export = naturalCompare; | ||
| 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 { | ||
| desc?: boolean; | ||
| } | ||
| /** | ||
| * Compare alphanumeric strings the same way a human would, | ||
| * using a natural order algorithm | ||
| * (originally known as the alphanum algorithm) | ||
| * where numeric characters are sorted | ||
| * based on their numeric values rather than their ASCII values. | ||
| */ | ||
| export declare function naturalCompare(a: any, b: any, opts?: IOptionsNaturalCompare): number; | ||
| export declare namespace naturalCompare { | ||
| export var createNew: typeof import(".").createNew; | ||
| export var compareCaseInsensitive: (a: any, b: any) => number; | ||
| var _a: typeof naturalCompare; | ||
| export { _a as default }; | ||
| } | ||
| /** | ||
| * create compare with preset options | ||
| */ | ||
| export declare function createNew(opts?: IOptionsNaturalCompare): (a: any, b: any) => number; | ||
| /** | ||
| * compare strings case-insensitively | ||
| */ | ||
| export declare const compareCaseInsensitive: (a: any, b: any) => number; | ||
| export default naturalCompare; |
+51
-2
@@ -8,4 +8,53 @@ "use strict"; | ||
| }; | ||
| const core_1 = __importDefault(require("./core")); | ||
| module.exports = core_1.default; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.compareCaseInsensitive = exports.createNew = exports.naturalCompare = void 0; | ||
| const string_natural_compare_1 = __importDefault(require("string-natural-compare")); | ||
| /** | ||
| * Compare alphanumeric strings the same way a human would, | ||
| * using a natural order algorithm | ||
| * (originally known as the alphanum algorithm) | ||
| * where numeric characters are sorted | ||
| * based on their numeric values rather than their ASCII values. | ||
| */ | ||
| function naturalCompare(a, b, opts) { | ||
| let i; | ||
| if (typeof a === 'number' && typeof b === 'number') { | ||
| i = a - b; | ||
| } | ||
| else { | ||
| if (typeof a === 'number') { | ||
| a = String(a); | ||
| } | ||
| else if (typeof b === 'number') { | ||
| b = String(b); | ||
| } | ||
| if (a === b) { | ||
| return 0; | ||
| } | ||
| i = string_natural_compare_1.default(a, b, opts); | ||
| } | ||
| if (i !== 0 && (opts === null || opts === void 0 ? void 0 : opts.desc)) { | ||
| i = 0 - i; | ||
| } | ||
| return i; | ||
| } | ||
| exports.naturalCompare = naturalCompare; | ||
| /** | ||
| * create compare with preset options | ||
| */ | ||
| function createNew(opts) { | ||
| return (a, b) => naturalCompare(a, b, opts); | ||
| } | ||
| exports.createNew = createNew; | ||
| /** | ||
| * compare strings case-insensitively | ||
| */ | ||
| exports.compareCaseInsensitive = createNew({ | ||
| caseInsensitive: true, | ||
| }); | ||
| naturalCompare.createNew = createNew; | ||
| naturalCompare.compareCaseInsensitive = exports.compareCaseInsensitive; | ||
| naturalCompare.default = naturalCompare; | ||
| Object.defineProperty(naturalCompare, "__esModule", { value: true }); | ||
| exports.default = naturalCompare; | ||
| //# sourceMappingURL=index.js.map |
+1
-1
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,kDAAoC;AAEpC,iBAAS,cAAc,CAAA","sourcesContent":["/**\n * Created by user on 2020/6/4.\n */\n\nimport naturalCompare from './core';\n\nexport = naturalCompare\n"]} | ||
| {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;AAEH,oFAAqD;AAmBrD;;;;;;GAMG;AACH,SAAgB,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,IAA6B;IAEjE,IAAI,CAAS,CAAC;IAEd,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,QAAQ,EAClD;QACC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;KACT;SAED;QACC,IAAI,OAAO,CAAC,KAAK,QAAQ,EACzB;YACC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;SACd;aACI,IAAI,OAAO,CAAC,KAAK,QAAQ,EAC9B;YACC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;SACd;QAED,IAAI,CAAC,KAAK,CAAC,EACX;YACC,OAAO,CAAC,CAAA;SACR;QAED,CAAC,GAAG,gCAAe,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAA;KAC/B;IAED,IAAI,CAAC,KAAK,CAAC,KAAI,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,CAAA,EACzB;QACC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;KACV;IAED,OAAO,CAAC,CAAA;AACT,CAAC;AAjCD,wCAiCC;AAED;;GAEG;AACH,SAAgB,SAAS,CAAC,IAA6B;IAEtD,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAA;AAC5C,CAAC;AAHD,8BAGC;AAED;;GAEG;AACU,QAAA,sBAAsB,GAAG,SAAS,CAAC;IAC/C,eAAe,EAAE,IAAI;CACrB,CAAC,CAAA;AAEF,cAAc,CAAC,SAAS,GAAG,SAAS,CAAC;AACrC,cAAc,CAAC,sBAAsB,GAAG,8BAAsB,CAAC;AAC/D,cAAc,CAAC,OAAO,GAAG,cAAc,CAAC;AAExC,MAAM,CAAC,cAAc,CAAC,cAAc,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAErE,kBAAe,cAAc,CAAA","sourcesContent":["/**\n * Created by user on 2020/6/4.\n */\n\nimport _naturalCompare from 'string-natural-compare';\n\nexport interface IOptionsStringNaturalCompare\n{\n\t/**\n\t * Set to true to compare strings case-insensitively. Default: false.\n\t */\n\tcaseInsensitive?: boolean,\n\t/**\n\t * A string of characters that define a custom character ordering. Default: undefined.\n\t */\n\talphabet?: string,\n}\n\nexport interface IOptionsNaturalCompare extends IOptionsStringNaturalCompare\n{\n\tdesc?: boolean,\n}\n\n/**\n * Compare alphanumeric strings the same way a human would,\n * using a natural order algorithm\n * (originally known as the alphanum algorithm)\n * where numeric characters are sorted\n * based on their numeric values rather than their ASCII values.\n */\nexport function naturalCompare(a, b, opts?: IOptionsNaturalCompare)\n{\n\tlet i: number;\n\n\tif (typeof a === 'number' && typeof b === 'number')\n\t{\n\t\ti = a - b\n\t}\n\telse\n\t{\n\t\tif (typeof a === 'number')\n\t\t{\n\t\t\ta = String(a);\n\t\t}\n\t\telse if (typeof b === 'number')\n\t\t{\n\t\t\tb = String(b);\n\t\t}\n\n\t\tif (a === b)\n\t\t{\n\t\t\treturn 0\n\t\t}\n\n\t\ti = _naturalCompare(a, b, opts)\n\t}\n\n\tif (i !== 0 && opts?.desc)\n\t{\n\t\ti = 0 - i;\n\t}\n\n\treturn i\n}\n\n/**\n * create compare with preset options\n */\nexport function createNew(opts?: IOptionsNaturalCompare)\n{\n\treturn (a, b) => naturalCompare(a, b, opts)\n}\n\n/**\n * compare strings case-insensitively\n */\nexport const compareCaseInsensitive = createNew({\n\tcaseInsensitive: true,\n})\n\nnaturalCompare.createNew = createNew;\nnaturalCompare.compareCaseInsensitive = compareCaseInsensitive;\nnaturalCompare.default = naturalCompare;\n\nObject.defineProperty(naturalCompare, \"__esModule\", { value: true });\n\nexport default naturalCompare\n"]} |
+2
-2
| { | ||
| "name": "@bluelovers/string-natural-compare", | ||
| "version": "1.0.7", | ||
| "version": "1.1.1", | ||
| "description": "Compare alphanumeric strings the same way a human would, using a natural order algorithm", | ||
@@ -38,3 +38,3 @@ "homepage": "https://github.com/bluelovers/ws-array/tree/master/packages/string-natural-compare#readme", | ||
| }, | ||
| "gitHead": "315a9098b8d606eb0be8a9edc7b5fe0674c452d1" | ||
| "gitHead": "37f990c1d60adba476a07b0dda67f4df723ef2f8" | ||
| } |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
12011
15.38%12
33.33%132
18.92%1
Infinity%