qsu 1.6.4 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -7
- package/dist/_types/global.d.ts +33 -0
- package/dist/array/arrCount.d.ts +2 -0
- package/dist/array/arrCount.js +1 -0
- package/dist/array/arrGroupByMaxCount.d.ts +1 -0
- package/dist/array/arrGroupByMaxCount.js +1 -0
- package/dist/array/arrMove.d.ts +2 -0
- package/dist/array/arrMove.js +1 -0
- package/dist/array/arrRepeat.d.ts +2 -0
- package/dist/array/arrRepeat.js +1 -0
- package/dist/array/arrShuffle.d.ts +1 -0
- package/dist/array/arrShuffle.js +1 -0
- package/dist/array/arrTo1dArray.d.ts +1 -0
- package/dist/array/arrTo1dArray.js +1 -0
- package/dist/array/arrUnique.d.ts +1 -0
- package/dist/array/arrUnique.js +1 -0
- package/dist/array/arrWithDefault.d.ts +1 -0
- package/dist/array/arrWithDefault.js +1 -0
- package/dist/array/arrWithNumber.d.ts +1 -0
- package/dist/array/arrWithNumber.js +1 -0
- package/dist/array/average.d.ts +1 -0
- package/dist/array/average.js +1 -0
- package/dist/array/index.d.ts +12 -0
- package/dist/array/index.js +1 -0
- package/dist/array/sortByObjectKey.d.ts +1 -0
- package/dist/array/sortByObjectKey.js +1 -0
- package/dist/array/sortNumeric.d.ts +1 -0
- package/dist/array/sortNumeric.js +1 -0
- package/dist/date/createDateListFromRange.d.ts +1 -0
- package/dist/date/createDateListFromRange.js +1 -0
- package/dist/date/dateToYYYYMMDD.d.ts +1 -0
- package/dist/date/dateToYYYYMMDD.js +1 -0
- package/dist/date/dayDiff.d.ts +1 -0
- package/dist/date/dayDiff.js +1 -0
- package/dist/date/index.d.ts +5 -0
- package/dist/date/index.js +1 -0
- package/dist/date/isValidDate.d.ts +1 -0
- package/dist/date/isValidDate.js +1 -0
- package/dist/date/today.d.ts +1 -0
- package/dist/date/today.js +1 -0
- package/dist/encrypt/decodeBase64.d.ts +1 -0
- package/dist/encrypt/decodeBase64.js +1 -0
- package/dist/encrypt/decrypt.d.ts +1 -0
- package/dist/encrypt/decrypt.js +1 -0
- package/dist/encrypt/encodeBase64.d.ts +1 -0
- package/dist/encrypt/encodeBase64.js +1 -0
- package/dist/encrypt/encrypt.d.ts +1 -0
- package/dist/encrypt/encrypt.js +1 -0
- package/dist/encrypt/index.d.ts +9 -0
- package/dist/encrypt/index.js +1 -0
- package/dist/encrypt/md5Hash.d.ts +1 -0
- package/dist/encrypt/md5Hash.js +1 -0
- package/dist/encrypt/objectId.d.ts +1 -0
- package/dist/encrypt/objectId.js +1 -0
- package/dist/encrypt/sha1Hash.d.ts +1 -0
- package/dist/encrypt/sha1Hash.js +1 -0
- package/dist/encrypt/sha256Hash.d.ts +1 -0
- package/dist/encrypt/sha256Hash.js +1 -0
- package/dist/encrypt/strToNumberHash.d.ts +1 -0
- package/dist/encrypt/strToNumberHash.js +1 -0
- package/dist/file/createDirectory.d.ts +1 -0
- package/dist/file/createDirectory.js +1 -0
- package/dist/file/createFile.d.ts +1 -0
- package/dist/file/createFile.js +1 -0
- package/dist/file/createFileWithDummy.d.ts +1 -0
- package/dist/file/createFileWithDummy.js +1 -0
- package/dist/file/deleteAllFileFromDirectory.d.ts +1 -0
- package/dist/file/deleteAllFileFromDirectory.js +1 -0
- package/dist/file/deleteFile.d.ts +1 -0
- package/dist/file/deleteFile.js +1 -0
- package/dist/file/getFileExtension.d.ts +1 -0
- package/dist/file/getFileExtension.js +1 -0
- package/dist/file/getFileHash.d.ts +1 -0
- package/dist/file/getFileHash.js +1 -0
- package/dist/file/getFileInfo.d.ts +2 -0
- package/dist/file/getFileInfo.js +1 -0
- package/dist/file/getFileName.d.ts +1 -0
- package/dist/file/getFileName.js +1 -0
- package/dist/file/getFilePathLevel.d.ts +1 -0
- package/dist/file/getFilePathLevel.js +1 -0
- package/dist/file/getFileSize.d.ts +2 -0
- package/dist/file/getFileSize.js +1 -0
- package/dist/file/getParentFilePath.d.ts +1 -0
- package/dist/file/getParentFilePath.js +1 -0
- package/dist/file/headFile.d.ts +1 -0
- package/dist/file/headFile.js +1 -0
- package/dist/file/index.d.ts +22 -0
- package/dist/file/index.js +1 -0
- package/dist/file/isFileExists.d.ts +1 -0
- package/dist/file/isFileExists.js +1 -0
- package/dist/file/isFileHidden.d.ts +1 -0
- package/dist/file/isFileHidden.js +1 -0
- package/dist/file/isValidFileName.d.ts +1 -0
- package/dist/file/isValidFileName.js +1 -0
- package/dist/file/joinFilePath.d.ts +1 -0
- package/dist/file/joinFilePath.js +1 -0
- package/dist/file/moveFile.d.ts +1 -0
- package/dist/file/moveFile.js +1 -0
- package/dist/file/normalizeFile.d.ts +1 -0
- package/dist/file/normalizeFile.js +1 -0
- package/dist/file/tailFile.d.ts +1 -0
- package/dist/file/tailFile.js +1 -0
- package/dist/file/toPosixFilePath.d.ts +1 -0
- package/dist/file/toPosixFilePath.js +1 -0
- package/dist/file/toValidFilePath.d.ts +1 -0
- package/dist/file/toValidFilePath.js +1 -0
- package/dist/format/duration.d.ts +2 -0
- package/dist/format/duration.js +1 -0
- package/dist/format/index.d.ts +4 -0
- package/dist/format/index.js +1 -0
- package/dist/format/numberFormat.d.ts +1 -0
- package/dist/format/numberFormat.js +1 -0
- package/dist/format/safeJSONParse.d.ts +2 -0
- package/dist/format/safeJSONParse.js +1 -0
- package/dist/format/safeParseInt.d.ts +1 -0
- package/dist/format/safeParseInt.js +1 -0
- package/dist/index.d.ts +11 -9
- package/dist/index.js +1 -1
- package/dist/math/div.d.ts +2 -0
- package/dist/math/div.js +1 -0
- package/dist/math/index.d.ts +5 -0
- package/dist/math/index.js +1 -0
- package/dist/math/mul.d.ts +2 -0
- package/dist/math/mul.js +1 -0
- package/dist/math/numRandom.d.ts +1 -0
- package/dist/math/numRandom.js +1 -0
- package/dist/math/sub.d.ts +2 -0
- package/dist/math/sub.js +1 -0
- package/dist/math/sum.d.ts +2 -0
- package/dist/math/sum.js +1 -0
- package/dist/misc/debounce.d.ts +2 -0
- package/dist/misc/debounce.js +1 -0
- package/dist/misc/funcTimes.d.ts +2 -0
- package/dist/misc/funcTimes.js +1 -0
- package/dist/misc/index.d.ts +3 -0
- package/dist/misc/index.js +1 -0
- package/dist/misc/sleep.d.ts +2 -0
- package/dist/misc/sleep.js +1 -0
- package/dist/object/index.d.ts +8 -0
- package/dist/object/index.js +1 -0
- package/dist/object/objDeleteKeyByValue.d.ts +2 -0
- package/dist/object/objDeleteKeyByValue.js +1 -0
- package/dist/object/objFindItemRecursiveByKey.d.ts +2 -0
- package/dist/object/objFindItemRecursiveByKey.js +1 -0
- package/dist/object/objMergeNewKey.d.ts +4 -0
- package/dist/object/objMergeNewKey.js +1 -0
- package/dist/object/objTo1d.d.ts +2 -0
- package/dist/object/objTo1d.js +1 -0
- package/dist/object/objToArray.d.ts +2 -0
- package/dist/object/objToArray.js +1 -0
- package/dist/object/objToPrettyStr.d.ts +2 -0
- package/dist/object/objToPrettyStr.js +1 -0
- package/dist/object/objToQueryString.d.ts +2 -0
- package/dist/object/objToQueryString.js +1 -0
- package/dist/object/objUpdate.d.ts +2 -0
- package/dist/object/objUpdate.js +1 -0
- package/dist/string/capitalizeEachWords.d.ts +1 -0
- package/dist/string/capitalizeEachWords.js +1 -0
- package/dist/string/capitalizeEverySentence.d.ts +1 -0
- package/dist/string/capitalizeEverySentence.js +1 -0
- package/dist/string/capitalizeFirst.d.ts +1 -0
- package/dist/string/capitalizeFirst.js +1 -0
- package/dist/string/index.d.ts +17 -0
- package/dist/string/index.js +1 -0
- package/dist/string/removeNewLine.d.ts +1 -0
- package/dist/string/removeNewLine.js +1 -0
- package/dist/string/removeSpecialChar.d.ts +1 -0
- package/dist/string/removeSpecialChar.js +1 -0
- package/dist/string/replaceBetween.d.ts +1 -0
- package/dist/string/replaceBetween.js +1 -0
- package/dist/string/split.d.ts +2 -0
- package/dist/string/split.js +1 -0
- package/dist/string/strBlindRandom.d.ts +2 -0
- package/dist/string/strBlindRandom.js +1 -0
- package/dist/string/strCount.d.ts +1 -0
- package/dist/string/strCount.js +1 -0
- package/dist/string/strRandom.d.ts +2 -0
- package/dist/string/strRandom.js +1 -0
- package/dist/string/strShuffle.d.ts +1 -0
- package/dist/string/strShuffle.js +1 -0
- package/dist/string/strToAscii.d.ts +1 -0
- package/dist/string/strToAscii.js +1 -0
- package/dist/string/strUnique.d.ts +1 -0
- package/dist/string/strUnique.js +1 -0
- package/dist/string/trim.d.ts +1 -0
- package/dist/string/trim.js +1 -0
- package/dist/string/truncate.d.ts +2 -0
- package/dist/string/truncate.js +1 -0
- package/dist/string/truncateExpect.d.ts +2 -0
- package/dist/string/truncateExpect.js +1 -0
- package/dist/string/urlJoin.d.ts +1 -0
- package/dist/string/urlJoin.js +1 -0
- package/dist/verify/between.d.ts +1 -0
- package/dist/verify/between.js +1 -0
- package/dist/verify/contains.d.ts +1 -0
- package/dist/verify/contains.js +1 -0
- package/dist/verify/index.d.ts +11 -0
- package/dist/verify/index.js +1 -0
- package/dist/verify/is2dArray.d.ts +1 -0
- package/dist/verify/is2dArray.js +1 -0
- package/dist/verify/isEmail.d.ts +1 -0
- package/dist/verify/isEmail.js +1 -0
- package/dist/verify/isEmpty.d.ts +1 -0
- package/dist/verify/isEmpty.js +1 -0
- package/dist/verify/isEqual.d.ts +1 -0
- package/dist/verify/isEqual.js +1 -0
- package/dist/verify/isEqualStrict.d.ts +1 -0
- package/dist/verify/isEqualStrict.js +1 -0
- package/dist/verify/isObject.d.ts +1 -0
- package/dist/verify/isObject.js +1 -0
- package/dist/verify/isTrueMinimumNumberOfTimes.d.ts +1 -0
- package/dist/verify/isTrueMinimumNumberOfTimes.js +1 -0
- package/dist/verify/isUrl.d.ts +1 -0
- package/dist/verify/isUrl.js +1 -0
- package/dist/verify/len.d.ts +1 -0
- package/dist/verify/len.js +1 -0
- package/dist/web/generateLicense.d.ts +2 -0
- package/dist/web/generateLicense.js +1 -0
- package/dist/web/index.d.ts +5 -0
- package/dist/web/index.js +1 -0
- package/dist/web/isBotAgent.d.ts +1 -0
- package/dist/web/isBotAgent.js +1 -0
- package/dist/web/isMatchPathname.d.ts +1 -0
- package/dist/web/isMatchPathname.js +1 -0
- package/dist/web/isMobile.d.ts +1 -0
- package/dist/web/isMobile.js +1 -0
- package/dist/web/removeLocalePrefix.d.ts +1 -0
- package/dist/web/removeLocalePrefix.js +1 -0
- package/package.json +8 -8
- package/dist/array.d.ts +0 -13
- package/dist/array.js +0 -1
- package/dist/date.d.ts +0 -5
- package/dist/date.js +0 -1
- package/dist/encrypt.d.ts +0 -9
- package/dist/encrypt.js +0 -1
- package/dist/format.d.ts +0 -8
- package/dist/format.js +0 -1
- package/dist/math.d.ts +0 -9
- package/dist/math.js +0 -1
- package/dist/misc.d.ts +0 -4
- package/dist/misc.js +0 -1
- package/dist/object.d.ts +0 -11
- package/dist/object.js +0 -1
- package/dist/string.d.ts +0 -19
- package/dist/string.js +0 -1
- package/dist/types/global.d.ts +0 -13
- package/dist/verify.d.ts +0 -11
- package/dist/verify.js +0 -1
- /package/dist/{types → _types}/global.js +0 -0
package/README.md
CHANGED
|
@@ -15,13 +15,6 @@
|
|
|
15
15
|
|
|
16
16
|
Installing and using the package and defining all the utility methods can be found on the documentation page below: https://qsu.cdget.com/getting-started/installation-javascript
|
|
17
17
|
|
|
18
|
-
## Family Packages
|
|
19
|
-
|
|
20
|
-
As a family package of `qsu`, it can be installed and used independently of the `qsu` package.
|
|
21
|
-
|
|
22
|
-
- **[qsu-fs](https://github.com/jooy2/qsu-fs)**: File listing and management utilities
|
|
23
|
-
- **[qsu-web](https://github.com/jooy2/qsu-web)**: Utilities for website front-end & back-end services
|
|
24
|
-
|
|
25
18
|
In addition, `qsu` is also available for the Dart language: https://github.com/jooy2/qsu-dart
|
|
26
19
|
|
|
27
20
|
## Contributing
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export type PositiveNumber<N extends number> = number extends N ? N : `${N}` extends `-${string}` ? never : N;
|
|
2
|
+
export type NumberValueObject = {
|
|
3
|
+
[key: string]: number;
|
|
4
|
+
};
|
|
5
|
+
export type AnyValueObject = {
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
};
|
|
8
|
+
export type DurationOptions = {
|
|
9
|
+
useShortString?: boolean;
|
|
10
|
+
useSpace?: boolean;
|
|
11
|
+
withZeroValue?: boolean;
|
|
12
|
+
separator?: string;
|
|
13
|
+
};
|
|
14
|
+
export interface FileInfo {
|
|
15
|
+
success: boolean;
|
|
16
|
+
isDirectory: boolean;
|
|
17
|
+
size: number;
|
|
18
|
+
sizeHumanized: string;
|
|
19
|
+
name: string;
|
|
20
|
+
dirname: string;
|
|
21
|
+
path: string;
|
|
22
|
+
ext: string | null;
|
|
23
|
+
created: number;
|
|
24
|
+
modified: number;
|
|
25
|
+
}
|
|
26
|
+
export interface LicenseOption {
|
|
27
|
+
author: string;
|
|
28
|
+
email?: string;
|
|
29
|
+
yearStart: string | number;
|
|
30
|
+
yearEnd?: string;
|
|
31
|
+
htmlBr?: boolean;
|
|
32
|
+
type: 'mit' | 'apache20';
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function arrCount(t){const n={};for(let o=0;o<t.length;o+=1){const r=t[o];n[r]=(n[r]||0)+1}return n}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function arrGroupByMaxCount(array: any[], maxLengthPerGroup?: number): any[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function arrGroupByMaxCount(t,n=1){const e=[],r=t.length;let u=[];for(let h=0;h<r;h+=1)u.length===n&&(e.push(u),u=[]),u.push(t[h]);return u.length>0&&e.push(u),e}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function arrMove(r,e,n){const o=r.length;if(o<=e||o<=n)throw new Error("Invalid move params");return r.splice(n,0,r.splice(e,1)[0]),r}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isObject as r}from"../verify/isObject.js";export function arrRepeat(t,e){if(!t||e<1||"object"!=typeof t)return[];const o=r(t),f=[];for(let r=0,p=e;r<p;r+=1)o?f.push(t):f.push(...t);return f}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function arrShuffle(array: any[]): any[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function arrShuffle(t){if(1===t.length)return t[0];const r=t;for(let n=t.length-1;n>0;n-=1){const o=Math.floor(Math.random()*(n+1));[r[n],r[o]]=[t[o],t[n]]}return r}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function arrTo1dArray(array: any[]): any[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{is2dArray as r}from"../verify/is2dArray.js";export function arrTo1dArray(t){const o=t=>{const e=[],n=t.length;for(let s=0;s<n;s+=1)"object"!=typeof t[s]?e.push(t[s]):r(t[s])?e.push(...o(t[s])):e.push(...t[s]);return e};return o(t)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function arrUnique(array: any[]): any[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{is2dArray as r}from"../verify/is2dArray.js";export function arrUnique(e){return r(e)?Array.from(new Set(e.map((r=>JSON.stringify(r)))),(r=>JSON.parse(r))):[...new Set(e)]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function arrWithDefault(defaultValue: any, length?: number): any[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function arrWithDefault(r,t=0){return t<1?[]:Array(t).fill(r)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function arrWithNumber(start: number, end: number): number[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function arrWithNumber(r,t){if(r>t)throw new Error("`end` is greater than `start`.");return Array.from({length:t-r+1},((t,e)=>e+r))}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function average(array: number[]): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function average(e){return e.reduce(((e,r)=>e+r),0)/e.length}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { arrCount } from './arrCount.js';
|
|
2
|
+
export { arrGroupByMaxCount } from './arrGroupByMaxCount.js';
|
|
3
|
+
export { arrMove } from './arrMove.js';
|
|
4
|
+
export { arrRepeat } from './arrRepeat.js';
|
|
5
|
+
export { arrShuffle } from './arrShuffle.js';
|
|
6
|
+
export { arrTo1dArray } from './arrTo1dArray.js';
|
|
7
|
+
export { arrUnique } from './arrUnique.js';
|
|
8
|
+
export { arrWithDefault } from './arrWithDefault.js';
|
|
9
|
+
export { arrWithNumber } from './arrWithNumber.js';
|
|
10
|
+
export { average } from './average.js';
|
|
11
|
+
export { sortByObjectKey } from './sortByObjectKey.js';
|
|
12
|
+
export { sortNumeric } from './sortNumeric.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{arrCount}from"./arrCount.js";export{arrGroupByMaxCount}from"./arrGroupByMaxCount.js";export{arrMove}from"./arrMove.js";export{arrRepeat}from"./arrRepeat.js";export{arrShuffle}from"./arrShuffle.js";export{arrTo1dArray}from"./arrTo1dArray.js";export{arrUnique}from"./arrUnique.js";export{arrWithDefault}from"./arrWithDefault.js";export{arrWithNumber}from"./arrWithNumber.js";export{average}from"./average.js";export{sortByObjectKey}from"./sortByObjectKey.js";export{sortNumeric}from"./sortNumeric.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function sortByObjectKey(array: any[], key: string, descending?: boolean, numerically?: boolean): any[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function sortByObjectKey(r,e,t=!1,o=!1){if(o){const o=new Intl.Collator([],{numeric:!0}),n=r.sort(((r,t)=>o.compare(r[e],t[e])));return t?n.reverse():n}return r.sort(((r,o)=>t?r[e]>o[e]?-1:r[e]<o[e]?1:0:r[e]<o[e]?-1:r[e]>o[e]?1:0))}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function sortNumeric(array: string[], descending?: boolean): string[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function sortNumeric(r,e=!1){const o=new Intl.Collator([],{numeric:!0}),t=r.sort(((r,e)=>o.compare(r,e)));return e?t.reverse():t}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createDateListFromRange(startDate: Date, endDate: Date): string[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{dateToYYYYMMDD as t}from"./dateToYYYYMMDD.js";import{isValidDate as e}from"./isValidDate.js";export function createDateListFromRange(r,a){if(!e(t(r))||!e(t(a)))throw new Error("Either the start date or end date is an invalid date.");if(Math.floor((Date.parse(a.toString())-Date.parse(r.toString()))/864e5)<0)throw new Error("The start date is more recent than the end date.");const o=t(a),n=[];let i=r.getFullYear(),s=r.getMonth()+1,d=r.getDate(),h="";const f=(t,e,r)=>`${t}-${e<10?"0":""}${e}-${r<10?"0":""}${r}`;for(;o!==h;){/[0-9]{4}-12-31/g.test(h)&&(i+=1,s=1,d=1);const t=f(i,s,d);e(t)?(d+=1,n.push(t),h=t):(s+=1,d=1,h=f(i,s,d))}return n}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function dateToYYYYMMDD(date: Date, separator?: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function dateToYYYYMMDD(t,e="-"){const $=t.getMonth()+1,n=t.getDate();return`${t.getFullYear()}${e}${$<10?`0${$}`:$}${e}${n<10?`0${n}`:n}`}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function dayDiff(date1: Date, date2?: Date): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function dayDiff(e,t){const a=t||new Date;return Math.ceil(Math.abs(a.getTime()-e.getTime())/864e5)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{createDateListFromRange}from"./createDateListFromRange.js";export{dateToYYYYMMDD}from"./dateToYYYYMMDD.js";export{dayDiff}from"./dayDiff.js";export{isValidDate}from"./isValidDate.js";export{today}from"./today.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isValidDate(dateYYYYMMDD: string): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function isValidDate(t){if(!/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/.test(t))throw new Error("The date format must be 'YYYY-MM-DD'");const d=t.split("-");return/^(?=\d)(?:(?:31(?!.(?:0?[2469]|11))|(?:30|29)(?!.0?2)|29(?=.0?2.(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:16|[2468][048]|[3579][26])00)(?:\x20|$))|(?:2[0-8]|1\d|0?[1-9]))([-./])(?:1[012]|0?[1-9])\1(?:1[6-9]|[2-9]\d)?\d\d(?:(?=\x20\d)\x20|$))?(((0?[1-9]|1[012])(:[0-5]\d){0,2}(\x20[AP]M))|([01]\d|2[0-3])(:[0-5]\d){1,2})?$/.test(`${parseInt(d[2],10)}-${parseInt(d[1],10)}-${parseInt(d[0],10)}`)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function today(separator?: string, yearFirst?: boolean): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function today(t="-",e=!0){const n=new Date,o=n.getMonth()+1,r=n.getDate(),g=[`${o<10?"0":""}${o}`,`${r<10?"0":""}${r}`];return e?g.unshift(n.getFullYear().toString()):g.push(n.getFullYear().toString()),g.join(t)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function decodeBase64(encodedStr: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function decodeBase64(e){return Buffer.from(e,"base64").toString("utf8")}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function decrypt(str: string, secret: string, algorithm?: string, toBase64?: boolean): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createDecipheriv as t}from"crypto";export function decrypt(r,e,f="aes-256-cbc",o=!1){if(!r||r.length<1)return"";const n=o?"base64":"hex",c=r.split(":"),i=t(f,e,Buffer.from(c.shift(),n));let u=i.update(Buffer.from(c.join(":"),n));return u=Buffer.concat([u,i.final()]),u.toString()}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function encodeBase64(str: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function encodeBase64(e){return Buffer.from(e,"utf8").toString("base64")}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function encrypt(str: string, secret: string, algorithm?: string, ivSize?: number, toBase64?: boolean): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createCipheriv as t,randomBytes as n}from"crypto";export function encrypt(r,e,o="aes-256-cbc",c=16,f=!1){if(!r||r.length<1)return"";const i=n(c),a=t(o,e,i);let p=a.update(r);p=Buffer.concat([p,a.final()]);const u=f?"base64":"hex";return`${i.toString(u)}:${p.toString(u)}`}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { decodeBase64 } from './decodeBase64.js';
|
|
2
|
+
export { decrypt } from './decrypt.js';
|
|
3
|
+
export { encodeBase64 } from './encodeBase64.js';
|
|
4
|
+
export { encrypt } from './encrypt.js';
|
|
5
|
+
export { md5Hash } from './md5Hash.js';
|
|
6
|
+
export { objectId } from './objectId.js';
|
|
7
|
+
export { sha1Hash } from './sha1Hash.js';
|
|
8
|
+
export { sha256Hash } from './sha256Hash.js';
|
|
9
|
+
export { strToNumberHash } from './strToNumberHash.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{decodeBase64}from"./decodeBase64.js";export{decrypt}from"./decrypt.js";export{encodeBase64}from"./encodeBase64.js";export{encrypt}from"./encrypt.js";export{md5Hash}from"./md5Hash.js";export{objectId}from"./objectId.js";export{sha1Hash}from"./sha1Hash.js";export{sha256Hash}from"./sha256Hash.js";export{strToNumberHash}from"./strToNumberHash.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function md5Hash(str: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createHash as t}from"crypto";export function md5Hash(r){return t("md5").update(r).digest("hex")}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function objectId(): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function objectId(){return Math.floor(Date.now()/1e3).toString(16)+"x".repeat(16).replace(/x/g,(()=>Math.floor(16*Math.random()).toString(16)))}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function sha1Hash(str: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createHash as t}from"crypto";export function sha1Hash(r){return t("sha1").update(r).digest("hex")}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function sha256Hash(str: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createHash as t}from"crypto";export function sha256Hash(r){return t("sha256").update(r).digest("hex")}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function strToNumberHash(str: string): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function strToNumberHash(r){if(!r)return 0;let t=0;for(let e=0;e<r.length;e+=1)t=(t<<5)-t+r.charCodeAt(e),t|=0;return t}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createDirectory(filePath: string, recursive?: boolean): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{mkdir as r}from"fs/promises";import{isFileExists as i}from"./isFileExists.js";export async function createDirectory(t,e=!0){try{await i(t)||await r(t,{recursive:e})}catch(r){if(r instanceof Error)throw new Error(r.message)}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createFile(filePath: string): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{open as t,utimes as a}from"fs/promises";export async function createFile(e){if(!e)return;const c=new Date;try{await a(e,c,c)}catch(a){const c=await t(e,"a");await c.close()}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createFileWithDummy(filePath: string, size: number): Promise<boolean>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{open as r}from"fs/promises";import{createFile as t}from"./createFile.js";export async function createFileWithDummy(e,i){if(!i||i<0)throw new Error("Size is required");try{if(0===i)return await t(e),!0;const a=await r(e,"w");return await a.write(Buffer.alloc(1),0,1,i-1),await a.close(),!0}catch(r){return!1}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function deleteAllFileFromDirectory(directoryPath: string): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readdir as t}from"fs/promises";import{join as e}from"path";import{deleteFile as o}from"./deleteFile.js";export async function deleteAllFileFromDirectory(r){let i=[];try{i=await t(r)}catch{}const l=i.length;for(let t=0;t<l;t+=1)await o(e(r,i[t]))}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function deleteFile(filePath: string): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{rm as e}from"fs/promises";export async function deleteFile(r){if(r)try{await e(r,{recursive:!0,force:!0})}catch{}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getFileExtension(filePath: string, isWindows?: boolean): string | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{extname as t}from"path";export function getFileExtension(l,e){let n=l.split(e?"\\":"/").pop();return n?(n=t(n)||n,-1===n.indexOf(".")?null:n.split(".")?.pop()?.toLowerCase()||null):null}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getFileHash(filePath: string, algorithm?: 'md5' | 'sha1' | 'sha256' | 'sha512'): Promise<string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createHash as r}from"crypto";import{createReadStream as o}from"fs";export async function getFileHash(e,n="md5"){return new Promise(((t,i)=>{if(!e)return void i(new Error("Invalid path"));const a=r(n),d=o(e);d.on("error",(r=>{i(r)})),d.on("data",(r=>{a.update(r)})),d.on("end",(()=>{t(a.digest("hex"))}))}))}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{stat as e}from"fs/promises";import{dirname as i,resolve as t}from"path";import{getFileExtension as r}from"./getFileExtension.js";import{getFileSize as s}from"./getFileSize.js";import{getFileName as o}from"./getFileName.js";export async function getFileInfo(m){const n=e=>Math.floor(new Date(e).getTime()/1e3);try{const a=await e(m);return{success:!0,isDirectory:a.isDirectory(),ext:r(m),size:a.size,sizeHumanized:s(a.size),name:o(m),dirname:i(m),path:t(m),created:n(a.ctime),modified:n(a.mtime)}}catch(e){if(e instanceof Error)throw new Error(e.message)}return{success:!1,isDirectory:!1,ext:null,size:0,sizeHumanized:"0 Bytes",name:"unknown",dirname:i(m),path:m,created:-1,modified:-1}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getFileName(filePath: string, withExtension?: boolean): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{basename as e,extname as n,win32 as a}from"path";export function getFileName(t,i=!1){return t?-1===t.indexOf("/")&&-1!==t.indexOf("\\")?i?a.basename(t):a.basename(t,n(t)):i?e(t):e(t,n(t)):""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getFilePathLevel(filePath: string): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{posix as t}from"path";import{toPosixFilePath as e}from"./toPosixFilePath.js";export function getFilePathLevel(o){return o?"/"===o?1:e(o.replace(/\\+$/,"")).split(t.sep).length:-1}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function getFileSize(t,o=2){const e=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"];if(t<1)return`0 ${e[0]}`;const B=Math.floor(Math.log(t)/Math.log(1024));return`${parseFloat((t/1024**B).toFixed(o<0?0:o))} ${e[B]}`}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getParentFilePath(filePath: string, isWindows?: boolean): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{toValidFilePath as t}from"./toValidFilePath.js";export function getParentFilePath(e,o){const i=e.split(o?"\\":"/");let n;return i.pop(),n=1===i.length?o?"C:\\":"/":i.join(o?"\\":"/"),t(n,o)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function headFile(filePath: string, length?: number): Promise<string | null>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readFile as r}from"fs/promises";export async function headFile(t,n=1){try{const e=(await r(t,"utf-8")).split("\n");let o="";for(let r=0,t=n;r<t;r+=1)o+=`${e[r]}${n<2||r===t-1?"":"\n"}`;return o.length<1?null:o}catch(r){if(r instanceof Error)throw new Error(r.message)}return null}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export { createDirectory } from './createDirectory.js';
|
|
2
|
+
export { createFile } from './createFile.js';
|
|
3
|
+
export { createFileWithDummy } from './createFileWithDummy.js';
|
|
4
|
+
export { deleteAllFileFromDirectory } from './deleteAllFileFromDirectory.js';
|
|
5
|
+
export { deleteFile } from './deleteFile.js';
|
|
6
|
+
export { getFileExtension } from './getFileExtension.js';
|
|
7
|
+
export { getFileHash } from './getFileHash.js';
|
|
8
|
+
export { getFileInfo } from './getFileInfo.js';
|
|
9
|
+
export { getFileName } from './getFileName.js';
|
|
10
|
+
export { getFilePathLevel } from './getFilePathLevel.js';
|
|
11
|
+
export { getFileSize } from './getFileSize.js';
|
|
12
|
+
export { getParentFilePath } from './getParentFilePath.js';
|
|
13
|
+
export { headFile } from './headFile.js';
|
|
14
|
+
export { isFileExists } from './isFileExists.js';
|
|
15
|
+
export { isFileHidden } from './isFileHidden.js';
|
|
16
|
+
export { isValidFileName } from './isValidFileName.js';
|
|
17
|
+
export { joinFilePath } from './joinFilePath.js';
|
|
18
|
+
export { moveFile } from './moveFile.js';
|
|
19
|
+
export { normalizeFile } from './normalizeFile.js';
|
|
20
|
+
export { tailFile } from './tailFile.js';
|
|
21
|
+
export { toPosixFilePath } from './toPosixFilePath.js';
|
|
22
|
+
export { toValidFilePath } from './toValidFilePath.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{createDirectory}from"./createDirectory.js";export{createFile}from"./createFile.js";export{createFileWithDummy}from"./createFileWithDummy.js";export{deleteAllFileFromDirectory}from"./deleteAllFileFromDirectory.js";export{deleteFile}from"./deleteFile.js";export{getFileExtension}from"./getFileExtension.js";export{getFileHash}from"./getFileHash.js";export{getFileInfo}from"./getFileInfo.js";export{getFileName}from"./getFileName.js";export{getFilePathLevel}from"./getFilePathLevel.js";export{getFileSize}from"./getFileSize.js";export{getParentFilePath}from"./getParentFilePath.js";export{headFile}from"./headFile.js";export{isFileExists}from"./isFileExists.js";export{isFileHidden}from"./isFileHidden.js";export{isValidFileName}from"./isValidFileName.js";export{joinFilePath}from"./joinFilePath.js";export{moveFile}from"./moveFile.js";export{normalizeFile}from"./normalizeFile.js";export{tailFile}from"./tailFile.js";export{toPosixFilePath}from"./toPosixFilePath.js";export{toValidFilePath}from"./toValidFilePath.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isFileExists(filePath: string): Promise<boolean>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{access as r}from"fs/promises";import{constants as t}from"fs";export async function isFileExists(i){try{return await r(i,t.F_OK),!0}catch(r){return!1}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isFileHidden(filePath: string, isWindows?: boolean): Promise<boolean>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{exec as e}from"child_process";export function isFileHidden(i,r=!1){return new Promise((t=>{r?e(`attrib "${i}"`,((e,r,o)=>{t(!(e||o||!r)&&r.replace(i,"").includes("H"))})):t(/(^|\/)\.[^/.]/.test(i.split("/")?.pop()||"/"))}))}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isValidFileName(filePath: string, unixType?: boolean): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getFileName as e}from"./getFileName.js";export function isValidFileName(t,i){let s;const l=e(t);return s=i?/(^\s+$)|(^\.+$)|([:/]+)/:/(^\s+$)|(^\.+$)|([<>:"/\\|?*]+)/,!s.test(l)&&l.length<=255}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function joinFilePath(isWindows: boolean, ...paths: string[]): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{posix as o,win32 as i}from"path";import{toValidFilePath as t}from"./toValidFilePath.js";export function joinFilePath(r,...n){return r?t(i.join(...n),!0):t(o.join(...n),!1)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function moveFile(filePath: string, targetFilePath: string): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{rename as o}from"fs/promises";export async function moveFile(i,e){i&&e&&await o(i,e)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function normalizeFile(filePath: string, normalizationForm?: 'NFD' | 'NFC' | 'NFKC' | 'NFKD' | undefined): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function normalizeFile(e,n){return!e||e.length<1?"":e.normalize(n)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function tailFile(filePath: string, length?: number): Promise<string | null>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{readFile as t}from"fs/promises";export async function tailFile(n,e=1){try{const r=(await t(n,"utf-8")).split("\n");let l="";r[r.length-1].length<1&&r.pop();for(let t=r.length,n=r.length-e;t>n;t-=1)l=`${r[t-1]}${l.length<1||t-1===n?"":"\n"}${l}`;return l.length<1?null:l}catch(t){if(t instanceof Error)throw new Error(t.message)}return null}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function toPosixFilePath(filePath: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function toPosixFilePath(e){return e.replace(/^\\\\\?\\/,"").replace(/\\/g,"/").replace(/\/\/+/g,"/")}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function toValidFilePath(filePath: string, isWindows?: boolean): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function toValidFilePath(e,t){if(t){let t=e;return t.length>2&&!/^[a-zA-Z]:/.test(t)&&(t=`\\${t}`),(t.match(/\\/g)||[]).length>1&&/\\$/.test(t)&&(t=t.replace(/\\$/,"")),/^[a-zA-Z]:$/.test(t)&&(t=`${t}\\`),t.replace(/\\{2,}/g,"\\")}let l=e;return/^\//.test(l)||(l=`/${l}`),l=l.replace(/\/{2,}/g,"/"),l.length>1&&(l=l.replace(/\/$/,"")),l}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function duration(e,r){const{useShortString:t=!1,useSpace:i=!0,withZeroValue:n=!1,separator:o=" "}={...r},d=[{name:"Millisecond",short:"ms",divider:1e3},{name:"Second",short:"S",divider:60},{name:"Minute",short:"M",divider:60},{name:"Hour",short:"H",divider:24},{name:"Day",short:"D",divider:31}],s=[];let a=e;for(let e=0;e<d.length;e+=1){const r=d[e];let o=a%r.divider;e===d.length-1?o=Math.trunc(a):a=(a-o)/r.divider,(n||!n&&0!==o)&&s.push(`${o}${i?" ":""}${t?r.short:`${r.name}${o<2?"":"s"}`}`)}return s.reverse().join(o)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{duration}from"./duration.js";export{numberFormat}from"./numberFormat.js";export{safeJSONParse}from"./safeJSONParse.js";export{safeParseInt}from"./safeParseInt.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function numberFormat(number: number | string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function numberFormat(r){return new Intl.NumberFormat("en-US",{roundingPriority:"morePrecision"}).format(r)}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function safeJSONParse(r,t={}){if(!r)return t;if(Array.isArray(r)||"object"==typeof r)try{return JSON.parse(JSON.stringify(r))}catch(r){return t}try{return JSON.parse(r)}catch(r){return t}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function safeParseInt(value: any, fallback?: number, radix?: number): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function safeParseInt(t,r=0,n=10){if(!t||t.toString().length<1)return r;try{return parseInt(t.toString().split(".")[0],n)}catch(t){return r}}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
export * from './array.js';
|
|
2
|
-
export * from './encrypt.js';
|
|
3
|
-
export * from './date.js';
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './
|
|
7
|
-
export * from './
|
|
8
|
-
export * from './
|
|
9
|
-
export * from './
|
|
1
|
+
export * from './array/index.js';
|
|
2
|
+
export * from './encrypt/index.js';
|
|
3
|
+
export * from './date/index.js';
|
|
4
|
+
export * from './file/index.js';
|
|
5
|
+
export * from './format/index.js';
|
|
6
|
+
export * from './math/index.js';
|
|
7
|
+
export * from './misc/index.js';
|
|
8
|
+
export * from './object/index.js';
|
|
9
|
+
export * from './string/index.js';
|
|
10
|
+
export * from './verify/index.js';
|
|
11
|
+
export * from './web/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"./array.js";export*from"./encrypt.js";export*from"./date.js";export*from"./format.js";export*from"./math.js";export*from"./misc.js";export*from"./object.js";export*from"./string.js";export*from"./verify.js";
|
|
1
|
+
export*from"./array/index.js";export*from"./encrypt/index.js";export*from"./date/index.js";export*from"./file/index.js";export*from"./format/index.js";export*from"./math/index.js";export*from"./misc/index.js";export*from"./object/index.js";export*from"./string/index.js";export*from"./verify/index.js";export*from"./web/index.js";
|
package/dist/math/div.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function div(...t){const e=t.length>0&&"object"==typeof t[0]?t[0]:t;let n=e[0];for(let t=1,o=e.length;t<o;t+=1)"number"==typeof e[t]&&(n/=e[t]);return n}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{div}from"./div.js";export{mul}from"./mul.js";export{numRandom}from"./numRandom.js";export{sub}from"./sub.js";export{sum}from"./sum.js";
|
package/dist/math/mul.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function mul(...t){const e=t.length>0&&"object"==typeof t[0]?t[0]:t;let n=e[0];for(let t=1,o=e.length;t<o;t+=1)"number"==typeof e[t]&&(n*=e[t]);return n}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function numRandom(min: number, max: number): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function numRandom(n,o){if(!n&&!o)return Math.random()>.5?1:0;const r=o||n,t=!o||n>=o?null:n;return Math.floor(Math.random()*(t?r-t+1:r+1))+(t||0)}
|
package/dist/math/sub.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function sub(...t){const e=t.length>0&&"object"==typeof t[0]?t[0]:t;let n=e[0];for(let t=1,o=e.length;t<o;t+=1)"number"==typeof e[t]&&(n-=e[t]);return n}
|