regexp-range
Advanced tools
Comparing version 1.0.4 to 1.0.5
/** | ||
* Created by user on 2018/5/7/007. | ||
*/ | ||
import { matchRange, getOptions, toRegExpString } from './src/core'; | ||
declare let _self2: typeof matchRange & { | ||
matchRange: typeof matchRange; | ||
getOptions: typeof getOptions; | ||
toRegExpString: typeof toRegExpString; | ||
TABLE_RANGE: { | ||
chinese: string[][]; | ||
circle: any; | ||
}; | ||
} & { | ||
default: typeof matchRange & { | ||
matchRange: typeof matchRange; | ||
getOptions: typeof getOptions; | ||
toRegExpString: typeof toRegExpString; | ||
TABLE_RANGE: { | ||
chinese: string[][]; | ||
circle: any; | ||
}; | ||
}; | ||
}; | ||
export = _self2; | ||
import { matchRange } from './src/core'; | ||
export = matchRange; |
@@ -6,9 +6,2 @@ "use strict"; | ||
const core_1 = require("./src/core"); | ||
let _self1 = core_1.matchRange; | ||
let _self2 = _self1; | ||
_self2.matchRange = core_1.matchRange; | ||
_self2.getOptions = core_1.getOptions; | ||
_self2.toRegExpString = core_1.toRegExpString; | ||
_self2.TABLE_RANGE = core_1.TABLE_RANGE; | ||
_self2.default = _self2; | ||
module.exports = _self2; | ||
module.exports = core_1.matchRange; |
{ | ||
"name": "regexp-range", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "create regex class range string `[一-十]` `[⓪-㊿]` ...", | ||
"keywords": [ | ||
"chinese", | ||
"expression", | ||
"fill", | ||
"generator", | ||
"number", | ||
"range", | ||
"re", | ||
"regex", | ||
"regexp", | ||
"regular", | ||
"regular expression", | ||
"util" | ||
], | ||
"homepage": "https://github.com/bluelovers/regexp-range#readme", | ||
@@ -23,2 +37,3 @@ "bugs": { | ||
"dependencies": { | ||
"array-hyper-unique": "^1.0.7", | ||
"fill-range": "^6.0.0", | ||
@@ -25,0 +40,0 @@ "japanese": "^1.2.0" |
@@ -7,6 +7,22 @@ /** | ||
export declare type IOptions = { | ||
/** | ||
* 字元範圍表 | ||
*/ | ||
dataTables?: typeof TABLE_RANGE; | ||
/** | ||
* 回傳 陣列 | ||
*/ | ||
arrayMode?: boolean; | ||
/** | ||
* 回傳 字串 | ||
*/ | ||
createRegExpString?: boolean; | ||
/** | ||
* 回傳由 [] 包覆的字串 | ||
*/ | ||
createRegExpClass?: boolean; | ||
/** | ||
* 找到第一個就停止 | ||
*/ | ||
findFirstOne?: boolean; | ||
}; | ||
@@ -16,7 +32,29 @@ export declare function matchRange(from: any, to: any, options: IOptions & { | ||
}): string; | ||
export declare namespace matchRange { | ||
var matchRange: typeof matchRange; | ||
var getOptions: typeof getOptions; | ||
var toRegExpString: typeof toRegExpString; | ||
var TABLE_RANGE: { | ||
chinese: string[][]; | ||
circle: string[][]; | ||
}; | ||
var fillRange: typeof fillRange; | ||
var default: typeof matchRange; | ||
} | ||
export declare function matchRange(from: any, to: any, options?: IOptions): string[]; | ||
export declare namespace matchRange { | ||
var matchRange: typeof matchRange; | ||
var getOptions: typeof getOptions; | ||
var toRegExpString: typeof toRegExpString; | ||
var TABLE_RANGE: { | ||
chinese: string[][]; | ||
circle: string[][]; | ||
}; | ||
var fillRange: typeof fillRange; | ||
var default: typeof matchRange; | ||
} | ||
export declare function toRegExpString(arr: string[], warpClass?: boolean): string; | ||
export declare function fillRange(from: any, to: any, options?: IOptions): string[]; | ||
export declare function getOptions(options: IOptions): IOptions; | ||
import * as self from '../index'; | ||
export default self; | ||
declare const _default: typeof import("./core"); | ||
export default _default; |
@@ -9,2 +9,3 @@ "use strict"; | ||
exports.TABLE_RANGE = table_1.default; | ||
const array_hyper_unique_1 = require("array-hyper-unique"); | ||
function matchRange(from, to, options = {}) { | ||
@@ -14,18 +15,25 @@ options = getOptions(options); | ||
let e = to; | ||
let ret = null; | ||
let ret = []; | ||
let findFirstOne = !!options.findFirstOne; | ||
Object | ||
.keys(options.dataTables) | ||
.some(function (key) { | ||
return options.dataTables[key].some(function (arr) { | ||
let bool; | ||
options.dataTables[key].some(function (arr) { | ||
let i = arr.indexOf(s); | ||
let j = arr.indexOf(e, i); | ||
if (i !== -1 && j !== -1) { | ||
ret = arr.slice(i, j + 1); | ||
return true; | ||
ret.push(...arr.slice(i, j + 1)); | ||
bool = true; | ||
return findFirstOne; | ||
} | ||
}); | ||
if (bool) { | ||
return true; | ||
} | ||
}); | ||
if (ret === null) { | ||
if (!ret || !ret.length) { | ||
return null; | ||
} | ||
array_hyper_unique_1.array_unique_overwrite(ret); | ||
if (options.createRegExpString) { | ||
@@ -80,3 +88,8 @@ return toRegExpString(ret, options.createRegExpClass); | ||
exports.getOptions = getOptions; | ||
const self = require("../index"); | ||
exports.default = self; | ||
matchRange.matchRange = matchRange; | ||
matchRange.getOptions = getOptions; | ||
matchRange.toRegExpString = toRegExpString; | ||
matchRange.TABLE_RANGE = table_1.default; | ||
matchRange.fillRange = fillRange; | ||
matchRange.default = matchRange; | ||
exports.default = exports; |
@@ -6,4 +6,4 @@ /** | ||
chinese: string[][]; | ||
circle: any; | ||
circle: string[][]; | ||
}; | ||
export default table_range; |
@@ -5,3 +5,3 @@ /** | ||
export declare let list_range_raw: (number | number[])[][]; | ||
export declare let list_range: any; | ||
export declare let list_range: string[][]; | ||
export default list_range; |
@@ -47,3 +47,2 @@ "use strict"; | ||
exports.list_range = util_1.listRawToRange(exports.list_range_raw); | ||
//console.log(list_range); | ||
exports.default = exports.list_range; |
@@ -5,3 +5,3 @@ /** | ||
export declare let list_range_raw: number[][][]; | ||
export declare let list_range: any; | ||
export declare let list_range: string[][]; | ||
export default list_range; |
/** | ||
* Created by user on 2018/5/7/007. | ||
*/ | ||
export declare function listRawToRange(list_range_raw: any): any; | ||
import * as self from './util'; | ||
export default self; | ||
export declare function listRawToRange(list_range_raw: any): string[][]; | ||
declare const _default: typeof import("./util"); | ||
export default _default; |
@@ -8,3 +8,3 @@ "use strict"; | ||
return list_range_raw.reduce(function (a, data) { | ||
let c = data.reduce(function (a, v) { | ||
let c = data.reduce(function (a2, v) { | ||
let s; | ||
@@ -33,11 +33,10 @@ if (typeof v == 'number') { | ||
if (Array.isArray(s)) { | ||
a = a.concat(s); | ||
a2 = a2.concat(s); | ||
} | ||
else { | ||
a.push(s); | ||
a2.push(s); | ||
} | ||
return a; | ||
return a2; | ||
}, []); | ||
a.push(c); | ||
//console.log(c.length); | ||
return a; | ||
@@ -47,3 +46,2 @@ }, []); | ||
exports.listRawToRange = listRawToRange; | ||
const self = require("./util"); | ||
exports.default = self; | ||
exports.default = exports; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10918
342
3
+ Addedarray-hyper-unique@^1.0.7
+ Addedarray-hyper-unique@1.1.10(transitive)
+ Addeddeep-eql@4.1.4(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedtslib@2.8.1(transitive)
+ Addedtype-detect@4.1.0(transitive)