This commit is contained in:
zhujingjing 2023-11-12 21:58:32 +08:00
parent 698f4f22e4
commit 44149b70a1
Signed by: karlcw
GPG Key ID: B11805D3A0F5C671
7 changed files with 55 additions and 25 deletions

3
lib/index.d.ts vendored
View File

@ -1,3 +1,4 @@
import { withRecord, assignRecords, RecordClearMode } from "./commons/record-util"; import { withRecord, assignRecords, RecordClearMode } from "./commons/record-util";
import { stringTokenizer, equalsIgnoreCase, includeIgnoreCase } from "./commons/str-utils"; import { stringTokenizer, equalsIgnoreCase, includeIgnoreCase } from "./commons/str-utils";
export { stringTokenizer, withRecord, equalsIgnoreCase, includeIgnoreCase, assignRecords, RecordClearMode }; import { getFileExt, getFileName } from "./commons/file-util";
export { stringTokenizer, withRecord, equalsIgnoreCase, includeIgnoreCase, assignRecords, RecordClearMode, getFileExt, getFileName, };

View File

@ -1,5 +1,5 @@
var c = /* @__PURE__ */ ((e) => (e[e.delete = 2] = "delete", e[e.reset = 1] = "reset", e))(c || {}); var h = /* @__PURE__ */ ((e) => (e[e.delete = 2] = "delete", e[e.reset = 1] = "reset", e))(h || {});
const g = (e) => ({ const a = (e) => ({
clear: function(t = 2) { clear: function(t = 2) {
t === 1 ? Object.keys(e).forEach((n) => { t === 1 ? Object.keys(e).forEach((n) => {
e[n] = void 0; e[n] = void 0;
@ -14,7 +14,7 @@ const g = (e) => ({
), Object.assign(e, t); ), Object.assign(e, t);
} }
}); });
function p(...e) { function x(...e) {
let t = e ?? []; let t = e ?? [];
return { return {
test: function(n) { test: function(n) {
@ -32,35 +32,45 @@ function p(...e) {
} }
}; };
} }
function y(e, t, n) { function d(e, t, n) {
const i = t, s = n || t; const i = t, s = n || t;
return function(r) { return function(r) {
const u = [], l = r.matchAll(e); const u = [], o = r.matchAll(e);
let f = 0; let f = 0;
for (const o of l) { for (const l of o) {
const h = r.slice(f, o.index); const c = r.slice(f, l.index);
h && u.push(s(h, !1)), u.push(i(o[0], !0)), f = o.index + o[0].length; c && u.push(s(c, !1)), u.push(i(l[0], !0)), f = l.index + l[0].length;
} }
return f < r.length && u.push(s(r.slice(f), !1)), u; return f < r.length && u.push(s(r.slice(f), !1)), u;
}; };
} }
function a(e, t) { function g(e, t) {
return typeof e == "string" && typeof t == "string" ? e.toLowerCase() === t.toLowerCase() : e === void 0 && t === void 0; return typeof e == "string" && typeof t == "string" ? e.toLowerCase() === t.toLowerCase() : e === void 0 && t === void 0;
} }
const m = (e, t) => { const p = (e, t) => {
for (let n = 0; n < e.length; n++) { for (let n = 0; n < e.length; n++) {
let i = e[n]; let i = e[n];
if (a(i, t)) if (g(i, t))
return !0; return !0;
} }
return !1; return !1;
}; };
function y(e) {
const t = e.lastIndexOf(".");
return t === -1 ? "" : e.substring(t + 1);
}
function O(e) {
let t = e.lastIndexOf("/");
return t === -1 && (t = e.lastIndexOf("\\"), t === -1) ? e : e.substring(t + 1);
}
export { export {
c as RecordClearMode, h as RecordClearMode,
p as assignRecords, x as assignRecords,
a as equalsIgnoreCase, g as equalsIgnoreCase,
m as includeIgnoreCase, y as getFileExt,
y as stringTokenizer, O as getFileName,
g as withRecord p as includeIgnoreCase,
d as stringTokenizer,
a as withRecord
}; };
//# sourceMappingURL=index.es.js.map //# sourceMappingURL=index.es.js.map

File diff suppressed because one or more lines are too long

View File

@ -1,2 +1,2 @@
(function(r,o){typeof exports=="object"&&typeof module<"u"?o(exports):typeof define=="function"&&define.amd?define(["exports"],o):(r=typeof globalThis<"u"?globalThis:r||self,o(r["ez-common-ts"]={}))})(this,function(r){"use strict";var o=(e=>(e[e.delete=2]="delete",e[e.reset=1]="reset",e))(o||{});const g=e=>({clear:function(n=2){n===1?Object.keys(e).forEach(t=>{e[t]=void 0}):n===2&&Object.keys(e).forEach(t=>{delete e[t]})},replace:function(n){this.clear(2),Object.assign(e,n)}});function m(...e){let n=e??[];return{test:function(t){if(n.length<=1)return n.length===1?n[0]:[];let u=t??function(s,i){return s===i};return n.reduce((s,i)=>(i&&i.length>0&&(s.length===0?s.push(...i):i.forEach(f=>{s.some(l=>u(l,f))||s.push(f)})),s),[])},path:function(...t){return this.test((u,s)=>t.every(i=>u[i]===s[i]))}}}function p(e,n,t){const u=n,s=t||n;return function(i){const f=[],a=i.matchAll(e);let l=0;for(const c of a){const d=i.slice(l,c.index);d&&f.push(s(d,!1)),f.push(u(c[0],!0)),l=c.index+c[0].length}return l<i.length&&f.push(s(i.slice(l),!1)),f}}function h(e,n){return typeof e=="string"&&typeof n=="string"?e.toLowerCase()===n.toLowerCase():e===void 0&&n===void 0}const y=(e,n)=>{for(let t=0;t<e.length;t++){let u=e[t];if(h(u,n))return!0}return!1};r.RecordClearMode=o,r.assignRecords=m,r.equalsIgnoreCase=h,r.includeIgnoreCase=y,r.stringTokenizer=p,r.withRecord=g,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})}); (function(r,o){typeof exports=="object"&&typeof module<"u"?o(exports):typeof define=="function"&&define.amd?define(["exports"],o):(r=typeof globalThis<"u"?globalThis:r||self,o(r["ez-common-ts"]={}))})(this,function(r){"use strict";var o=(e=>(e[e.delete=2]="delete",e[e.reset=1]="reset",e))(o||{});const a=e=>({clear:function(n=2){n===1?Object.keys(e).forEach(t=>{e[t]=void 0}):n===2&&Object.keys(e).forEach(t=>{delete e[t]})},replace:function(n){this.clear(2),Object.assign(e,n)}});function m(...e){let n=e??[];return{test:function(t){if(n.length<=1)return n.length===1?n[0]:[];let u=t??function(s,i){return s===i};return n.reduce((s,i)=>(i&&i.length>0&&(s.length===0?s.push(...i):i.forEach(f=>{s.some(l=>u(l,f))||s.push(f)})),s),[])},path:function(...t){return this.test((u,s)=>t.every(i=>u[i]===s[i]))}}}function y(e,n,t){const u=n,s=t||n;return function(i){const f=[],g=i.matchAll(e);let l=0;for(const c of g){const h=i.slice(l,c.index);h&&f.push(s(h,!1)),f.push(u(c[0],!0)),l=c.index+c[0].length}return l<i.length&&f.push(s(i.slice(l),!1)),f}}function d(e,n){return typeof e=="string"&&typeof n=="string"?e.toLowerCase()===n.toLowerCase():e===void 0&&n===void 0}const I=(e,n)=>{for(let t=0;t<e.length;t++){let u=e[t];if(d(u,n))return!0}return!1};function O(e){const n=e.lastIndexOf(".");return n===-1?"":e.substring(n+1)}function v(e){let n=e.lastIndexOf("/");return n===-1&&(n=e.lastIndexOf("\\"),n===-1)?e:e.substring(n+1)}r.RecordClearMode=o,r.assignRecords=m,r.equalsIgnoreCase=d,r.getFileExt=O,r.getFileName=v,r.includeIgnoreCase=I,r.stringTokenizer=y,r.withRecord=a,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})});
//# sourceMappingURL=index.umd.js.map //# sourceMappingURL=index.umd.js.map

File diff suppressed because one or more lines are too long

View File

@ -9,6 +9,7 @@
"types": "./lib/index.d.ts", "types": "./lib/index.d.ts",
"scripts": { "scripts": {
"build": "tsc && vite build", "build": "tsc && vite build",
"push": "tsc && vite build && git commit -am \"build\" && git push",
"test": "vitest" "test": "vitest"
}, },
"devDependencies": { "devDependencies": {
@ -28,4 +29,4 @@
"dependencies": { "dependencies": {
"vitest": "^0.34.6" "vitest": "^0.34.6"
} }
} }

View File

@ -1,4 +1,22 @@
import { withRecord, assignRecords, RecordClearMode } from "./commons/record-util"; import {
import { stringTokenizer, equalsIgnoreCase, includeIgnoreCase } from "./commons/str-utils"; withRecord,
assignRecords,
RecordClearMode,
} from "./commons/record-util";
import {
stringTokenizer,
equalsIgnoreCase,
includeIgnoreCase,
} from "./commons/str-utils";
import { getFileExt, getFileName } from "./commons/file-util";
export { stringTokenizer, withRecord, equalsIgnoreCase, includeIgnoreCase, assignRecords, RecordClearMode }; export {
stringTokenizer,
withRecord,
equalsIgnoreCase,
includeIgnoreCase,
assignRecords,
RecordClearMode,
getFileExt,
getFileName,
};