build
This commit is contained in:
parent
a6c221aca4
commit
4739183324
34
lib/commons/file-util.d.ts
vendored
34
lib/commons/file-util.d.ts
vendored
|
|
@ -5,11 +5,39 @@
|
||||||
*/
|
*/
|
||||||
export declare function getFileExt(fileName: string): string;
|
export declare function getFileExt(fileName: string): string;
|
||||||
/**
|
/**
|
||||||
* 获取文件名
|
* 获取文件全名(包含扩展名)
|
||||||
* 该函数接收一个表示文件路径的字符串作为参数,返回该路径中文件名部分。
|
* 该函数接收一个表示文件路径的字符串作为参数,返回该路径中文件名部分。
|
||||||
* 首先查找路径中最后一个斜杠或反斜杠的索引,若未找到则直接返回路径;
|
* 首先查找路径中最后一个斜杠或反斜杠的索引,若未找到则直接返回路径;
|
||||||
* 若找到,则使用substring方法提取最后一个斜杠或反斜杠后面的字符串作为文件名并返回。
|
* 若找到,则使用substring方法提取最后一个斜杠或反斜杠后面的字符串作为文件名并返回。
|
||||||
* @param path 文件路径
|
* @param path 文件路径
|
||||||
* @returns 文件名
|
* @returns 文件全名(包含扩展名)
|
||||||
*/
|
*/
|
||||||
export declare function getFileName(path: string): string;
|
export declare function getFileFullName(path: string): string;
|
||||||
|
/**
|
||||||
|
* 获取文件名不包含扩展名
|
||||||
|
*/
|
||||||
|
export declare function getFileNameWithoutExt(path: string): string;
|
||||||
|
/**
|
||||||
|
* 文件信息
|
||||||
|
*/
|
||||||
|
export interface IFileInfo {
|
||||||
|
/** 文件名(包含扩展名) */
|
||||||
|
fileName: string;
|
||||||
|
/**
|
||||||
|
* 文件名不带扩展名
|
||||||
|
*/
|
||||||
|
fileNameNoExt: string;
|
||||||
|
/** 文件扩展名 */
|
||||||
|
fileExtName: string;
|
||||||
|
/** 路径仅包含文件夹 */
|
||||||
|
pathOnly: string;
|
||||||
|
/** 完整路径 */
|
||||||
|
fullPath: string;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取文件信息
|
||||||
|
* @param path 文件路径
|
||||||
|
* @param platform 平台名称,默认为"win32"
|
||||||
|
* @returns 包含文件名、文件名不带扩展名、文件扩展名、路径仅包含文件夹、完整路径的对象
|
||||||
|
*/
|
||||||
|
export declare function getFileInfo(path: string, platform?: string): IFileInfo;
|
||||||
|
|
|
||||||
4
lib/index.d.ts
vendored
4
lib/index.d.ts
vendored
|
|
@ -1,4 +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";
|
||||||
import { getFileExt, getFileName } from "./commons/file-util";
|
import { getFileExt, getFileFullName, getFileNameWithoutExt, getFileInfo } from "./commons/file-util";
|
||||||
export { stringTokenizer, withRecord, equalsIgnoreCase, includeIgnoreCase, assignRecords, RecordClearMode, getFileExt, getFileName, };
|
export { stringTokenizer, withRecord, equalsIgnoreCase, includeIgnoreCase, assignRecords, RecordClearMode, getFileExt, getFileFullName as getFileName, getFileNameWithoutExt, getFileInfo, };
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
var h = /* @__PURE__ */ ((e) => (e[e.delete = 2] = "delete", e[e.reset = 1] = "reset", e))(h || {});
|
var a = /* @__PURE__ */ ((e) => (e[e.delete = 2] = "delete", e[e.reset = 1] = "reset", e))(a || {});
|
||||||
const a = (e) => ({
|
const h = (e) => ({
|
||||||
clear: function(t = 2) {
|
clear: function(t = 2) {
|
||||||
t === 1 ? Object.keys(e).forEach((n) => {
|
t === 1 ? Object.keys(e).forEach((s) => {
|
||||||
e[n] = void 0;
|
e[s] = void 0;
|
||||||
}) : t === 2 && Object.keys(e).forEach((n) => {
|
}) : t === 2 && Object.keys(e).forEach((s) => {
|
||||||
delete e[n];
|
delete e[s];
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
replace: function(t) {
|
replace: function(t) {
|
||||||
|
|
@ -14,63 +14,83 @@ const a = (e) => ({
|
||||||
), Object.assign(e, t);
|
), Object.assign(e, t);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
function x(...e) {
|
function d(...e) {
|
||||||
let t = e ?? [];
|
let t = e ?? [];
|
||||||
return {
|
return {
|
||||||
test: function(n) {
|
test: function(s) {
|
||||||
if (t.length <= 1)
|
if (t.length <= 1)
|
||||||
return t.length === 1 ? t[0] : [];
|
return t.length === 1 ? t[0] : [];
|
||||||
let i = n ?? function(s, r) {
|
let r = s ?? function(n, i) {
|
||||||
return s === r;
|
return n === i;
|
||||||
};
|
};
|
||||||
return t.reduce((s, r) => (r && r.length > 0 && (s.length === 0 ? s.push(...r) : r.forEach((u) => {
|
return t.reduce((n, i) => (i && i.length > 0 && (n.length === 0 ? n.push(...i) : i.forEach((u) => {
|
||||||
s.some((f) => i(f, u)) || s.push(u);
|
n.some((f) => r(f, u)) || n.push(u);
|
||||||
})), s), []);
|
})), n), []);
|
||||||
},
|
},
|
||||||
path: function(...n) {
|
path: function(...s) {
|
||||||
return this.test((i, s) => n.every((r) => i[r] === s[r]));
|
return this.test((r, n) => s.every((i) => r[i] === n[i]));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
function d(e, t, n) {
|
function m(e, t, s) {
|
||||||
const i = t, s = n || t;
|
const r = t, n = s || t;
|
||||||
return function(r) {
|
return function(i) {
|
||||||
const u = [], o = r.matchAll(e);
|
const u = [], l = i.matchAll(e);
|
||||||
let f = 0;
|
let f = 0;
|
||||||
for (const l of o) {
|
for (const o of l) {
|
||||||
const c = r.slice(f, l.index);
|
const c = i.slice(f, o.index);
|
||||||
c && u.push(s(c, !1)), u.push(i(l[0], !0)), f = l.index + l[0].length;
|
c && u.push(n(c, !1)), u.push(r(o[0], !0)), f = o.index + o[0].length;
|
||||||
}
|
}
|
||||||
return f < r.length && u.push(s(r.slice(f), !1)), u;
|
return f < i.length && u.push(n(i.slice(f), !1)), u;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
function g(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 p = (e, t) => {
|
const I = (e, t) => {
|
||||||
for (let n = 0; n < e.length; n++) {
|
for (let s = 0; s < e.length; s++) {
|
||||||
let i = e[n];
|
let r = e[s];
|
||||||
if (g(i, t))
|
if (g(r, t))
|
||||||
return !0;
|
return !0;
|
||||||
}
|
}
|
||||||
return !1;
|
return !1;
|
||||||
};
|
};
|
||||||
function y(e) {
|
function O(e) {
|
||||||
const t = e.lastIndexOf(".");
|
const t = e.lastIndexOf(".");
|
||||||
return t === -1 ? "" : e.substring(t + 1);
|
return t === -1 ? "" : e.substring(t + 1);
|
||||||
}
|
}
|
||||||
function O(e) {
|
function x(e) {
|
||||||
let t = e.lastIndexOf("/");
|
let t = e.lastIndexOf("/");
|
||||||
return t === -1 && (t = e.lastIndexOf("\\"), t === -1) ? e : e.substring(t + 1);
|
return t === -1 && (t = e.lastIndexOf("\\"), t === -1) ? e : e.substring(t + 1);
|
||||||
}
|
}
|
||||||
|
function E(e) {
|
||||||
|
const t = x(e), s = t.lastIndexOf(".");
|
||||||
|
return s === -1 ? t : t.substring(0, s);
|
||||||
|
}
|
||||||
|
function b(e, t = "win32") {
|
||||||
|
const s = t === "win32" ? "\\" : "/";
|
||||||
|
let r, n, i, u;
|
||||||
|
const l = e.lastIndexOf(s);
|
||||||
|
l === -1 ? (r = "", n = e) : (r = e.substring(0, l + 1), n = e.substring(l + 1));
|
||||||
|
const f = n.lastIndexOf(".");
|
||||||
|
return f === -1 ? (i = "", u = n) : (i = n.substring(f + 1), u = n.substring(0, f)), {
|
||||||
|
fileName: n,
|
||||||
|
fileNameNoExt: u,
|
||||||
|
fileExtName: i,
|
||||||
|
fullPath: e,
|
||||||
|
pathOnly: r
|
||||||
|
};
|
||||||
|
}
|
||||||
export {
|
export {
|
||||||
h as RecordClearMode,
|
a as RecordClearMode,
|
||||||
x as assignRecords,
|
d as assignRecords,
|
||||||
g as equalsIgnoreCase,
|
g as equalsIgnoreCase,
|
||||||
y as getFileExt,
|
O as getFileExt,
|
||||||
O as getFileName,
|
b as getFileInfo,
|
||||||
p as includeIgnoreCase,
|
x as getFileName,
|
||||||
d as stringTokenizer,
|
E as getFileNameWithoutExt,
|
||||||
a as withRecord
|
I as includeIgnoreCase,
|
||||||
|
m as stringTokenizer,
|
||||||
|
h as withRecord
|
||||||
};
|
};
|
||||||
//# sourceMappingURL=index.es.js.map
|
//# sourceMappingURL=index.es.js.map
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -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 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"})});
|
(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 m=e=>({clear:function(n=2){n===1?Object.keys(e).forEach(i=>{e[i]=void 0}):n===2&&Object.keys(e).forEach(i=>{delete e[i]})},replace:function(n){this.clear(2),Object.assign(e,n)}});function x(...e){let n=e??[];return{test:function(i){if(n.length<=1)return n.length===1?n[0]:[];let u=i??function(t,s){return t===s};return n.reduce((t,s)=>(s&&s.length>0&&(t.length===0?t.push(...s):s.forEach(f=>{t.some(l=>u(l,f))||t.push(f)})),t),[])},path:function(...i){return this.test((u,t)=>i.every(s=>u[s]===t[s]))}}}function I(e,n,i){const u=n,t=i||n;return function(s){const f=[],c=s.matchAll(e);let l=0;for(const g of c){const h=s.slice(l,g.index);h&&f.push(t(h,!1)),f.push(u(g[0],!0)),l=g.index+g[0].length}return l<s.length&&f.push(t(s.slice(l),!1)),f}}function a(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 i=0;i<e.length;i++){let u=e[i];if(a(u,n))return!0}return!1};function O(e){const n=e.lastIndexOf(".");return n===-1?"":e.substring(n+1)}function d(e){let n=e.lastIndexOf("/");return n===-1&&(n=e.lastIndexOf("\\"),n===-1)?e:e.substring(n+1)}function b(e){const n=d(e),i=n.lastIndexOf(".");return i===-1?n:n.substring(0,i)}function E(e,n="win32"){const i=n==="win32"?"\\":"/";let u,t,s,f;const c=e.lastIndexOf(i);c===-1?(u="",t=e):(u=e.substring(0,c+1),t=e.substring(c+1));const l=t.lastIndexOf(".");return l===-1?(s="",f=t):(s=t.substring(l+1),f=t.substring(0,l)),{fileName:t,fileNameNoExt:f,fileExtName:s,fullPath:e,pathOnly:u}}r.RecordClearMode=o,r.assignRecords=x,r.equalsIgnoreCase=a,r.getFileExt=O,r.getFileInfo=E,r.getFileName=d,r.getFileNameWithoutExt=b,r.includeIgnoreCase=y,r.stringTokenizer=I,r.withRecord=m,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
Loading…
Reference in New Issue
Block a user