xjs-common 11.0.0 → 11.0.1-alpha.2
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/LICENSE +201 -201
- package/build/const/ccy.d.ts +18 -0
- package/build/const/ccy.js +16 -0
- package/build/const/gender.d.ts +4 -0
- package/build/const/gender.js +5 -0
- package/build/const/http-method.d.ts +8 -0
- package/build/const/http-method.js +9 -0
- package/build/const/time-unit.d.ts +9 -0
- package/build/const/time-unit.js +10 -0
- package/build/const/types.d.ts +24 -0
- package/build/const/types.js +11 -0
- package/build/func/decorator/d-type.d.ts +24 -0
- package/build/func/decorator/d-type.js +68 -0
- package/build/func/decorator/transaction.d.ts +7 -0
- package/build/func/decorator/transaction.js +32 -0
- package/build/func/u-array.d.ts +40 -0
- package/build/func/u-array.js +67 -0
- package/build/func/u-http.d.ts +9 -0
- package/build/func/u-http.js +29 -0
- package/build/func/u-obj.d.ts +18 -0
- package/build/func/u-obj.js +41 -0
- package/build/func/u-string.d.ts +27 -0
- package/build/func/u-string.js +117 -0
- package/build/func/u-type.d.ts +25 -0
- package/build/func/u-type.js +55 -0
- package/build/func/u.d.ts +24 -0
- package/build/func/u.js +67 -0
- package/build/index.d.ts +14 -0
- package/build/index.js +14 -0
- package/build/obj/xjs-err.d.ts +5 -0
- package/build/obj/xjs-err.js +9 -0
- package/package.json +12 -11
- package/dist/index.js +0 -1
- package/dist/types.d.ts +0 -285
package/dist/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports["xjs-common"]=e():t["xjs-common"]=e()}(this,()=>(()=>{"use strict";var t,e,n,r,o={d:(t,e)=>{for(var n in e)o.o(e,n)&&!o.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},i={};o.r(i),o.d(i,{DType:()=>g,Gender:()=>n,HttpMethod:()=>r,TimeUnit:()=>e,Type:()=>t,UArray:()=>O,UHttp:()=>S,UObj:()=>M,UString:()=>w,UType:()=>j,XjsErr:()=>a,array2map:()=>p,bitor:()=>m,delay:()=>y,getJSTDate:()=>l,int2array:()=>d,resolveCcy:()=>u,retry:()=>h,s_ccy:()=>c,transaction:()=>P}),function(t){t.string="string",t.number="number",t.bigint="bigint",t.boolean="boolean",t.symbol="symbol",t.object="object",t[void 0]="undefined",t.null="null"}(t||(t={})),function(t){t[t.Year=1]="Year",t[t.Month=2]="Month",t[t.Day=3]="Day",t[t.Hour=4]="Hour",t[t.Min=5]="Min",t[t.Sec=6]="Sec",t[t.Msec=7]="Msec"}(e||(e={})),function(t){t[t.Male=0]="Male",t[t.Female=1]="Female"}(n||(n={})),function(t){t.Get="GET",t.Put="PUT",t.Post="POST",t.Delete="DELETE",t.Patch="PATCH",t.Connect="CONNECT"}(r||(r={}));const s={jpy:{crossUsd:"usd/jpy"},usd:{crossUsd:null},gbp:{crossUsd:"gbp/usd"},eur:{crossUsd:"eur/usd"},cad:{crossUsd:"cad/usd"},aud:{crossUsd:"aud/usd"}},c=(Object.entries(s).forEach(t=>{t[1].symbol=t[0],s[t[0]]=Object.freeze(t[1])}),Object.freeze(s));function u(t){const e=Object.keys(c).find(e=>t?.toLowerCase()==e);return e&&c[e]}class a extends Error{code;origin;constructor(t,e,n){super(`[XJS] ${e}`),this.code=t,this.origin=n}}const f=10;function l(t){return new Date((t?t.getTime():Date.now())+324e5)}function y(t){return new Promise(e=>setTimeout(e,1e3*t))}function d(t){const e=Number(t);if(Number.isNaN(e))throw new a(f,"size of the argument is not number.");return Array.from(Array(e).keys())}function p(t,e){const n=new Map;for(const r of t){const t=e(r);n.has(t)?n.get(t).push(r):n.set(t,[r])}return n}function m(...t){return t.reduce((t,e)=>t|e)}function h(t,e){const n=e?.logger??console,r=e?.count??1,o=t=>!(e?.errorCriterion&&!e.errorCriterion(t)||(n.warn(t),0)),i=n=>{if(n<0)throw new a(f,"failure exceeds retryable count.");let s=null;const c=()=>{try{s=t()}catch(t){if(!o(t))throw t;s=i(n-1)}return s instanceof Promise?new Promise((t,e)=>s.then(t).catch(r=>{o(r)?t(i(n-1)):e(r)})):s};return n<r&&e?.intervalPredicate&&(s=e?.intervalPredicate()),s instanceof Promise?s.then(()=>c()):c()};return i(r)}const b=Symbol.for("xjs:typeMap");var g,j,M,w,O,S;!function(e){function n(t,e,n){r(t,e,t=>{if(t.t)throw new a(30,"decorator to express type is duplicate.");t.t=n})}function r(t,e,n){const r=t[b]?Object.assign({},t[b]):{};r[e]??={t:null,req:!1,rec:!1,ary:null};const o=r[e];n(o);let i=null,s=null;if(o.t&&o.rec&&(i="type",s="recursive flag"),o.t&&o.ary&&(i="type",s="array"),o.ary&&o.rec&&(i="array",s="recursive flag"),i&&s)throw new a(30,`decorator to express ${i} and ${s} are exclusive.`);Object.defineProperty(t,b,{value:r,configurable:!0})}e.string=function(e,r){n(e,r,t.string)},e.number=function(e,r){n(e,r,t.number)},e.boolean=function(e,r){n(e,r,t.boolean)},e.required=function(t,e){r(t,e,t=>t.req=!0)},e.array=function(t={}){return(e,n)=>r(e,n,e=>e.ary=t)},e.recursive=function(t,e){r(t,e,t=>t.rec=!0)},e.keep=function(t,e){r(t,e,t=>{})}}(g||(g={})),function(e){function n(e){return null===e||typeof e===t.undefined}function r(t){return t[b]?Object.entries(t[b]).flatMap(e=>o(e[0],t[e[0]],e[1])):[]}function o(t,e,i){return n(e)?i.req?[t]:[]:i.t&&typeof e!==i.t?[t]:i.ary?Array.isArray(e)?e.flatMap(e=>o(t,e,i.ary)):[t]:i.rec?r(e).flatMap(e=>`${t}.${e}`):[]}e.isDefined=function(e){return typeof e!==t.undefined},e.isEmpty=n,e.isString=function(e){return typeof e===t.string},e.isNumber=function(e){return typeof e===t.number},e.isBigint=function(e){return typeof e===t.bigint},e.isBoolean=function(e){return typeof e===t.boolean},e.isSymbol=function(e){return typeof e===t.symbol},e.isObject=function(e){return typeof e===t.object},e.isArray=function(t,e){return Array.isArray(t)&&(!e||t.every(t=>typeof t===e))},e.validate=r,e.takeAsArray=function(t){return Array.isArray(t)?t:[t]}}(j||(j={})),function(t){t.assignProperties=function t(e,n,r,o){for(const i of r??Object.keys(n))j.isDefined(n[i])&&(o&&j.isObject(e[i])&&j.isObject(n[i])&&e[i]?.[b]?t(e[i],n[i],null,!0):e[i]=n[i]);return e},t.crop=function t(e,n,r){if(!n&&!e[b])return{};const o=n??Object.keys(e[b]);return Object.keys(e).filter(i=>(!n&&e[b]?.[i]?.rec&&e[i]&&t(e[i]),!!r===o.includes(i))).forEach(t=>delete e[t]),e}}(M||(M={})),function(t){function n(t,e){const n=t.toString().split("."),r=n[0].split("").reverse().join("");let o="";const i=Math.ceil(r.length/3);for(let t=0;t<i;t++)o+=t===i-1?r.substring(3*t):r.substring(3*t,3*(t+1))+",";const s=e+o.split("").reverse().join("");return 1===n.length?s:s+"."+n[1]}t.eq=function(t,e){return j.isString(t)&&j.isString(e)?t.trim()===e.trim():t===e},t.repeat=function(t,e){return d(e).map(e=>t).join("")},t.simpleTime=function(t){const n=(t?.date??new Date).toISOString().split(".")[0].replace(/[-T:]/g,"");return t?.unit===e.Msec?n:n.substring(0,14-2*(6-(t?.unit??e.Sec)))},t.generateRandomString=function(t){return d(t).map(t=>{let e=Math.floor(62*Math.random());const n=e-52;return n>=0?n.toString():(e>26&&(e+=6),String.fromCharCode(e+65))}).join("")},t.idx2az=function(t){let e="",n=t;for(;n>=0;)e=String.fromCharCode(n%26+97)+e,n=Math.floor(n/26)-1;return e.toUpperCase()},t.az2idx=function(t){if(!t?.match(/^[a-zA-Z]+$/))throw new a(20,"the parameter isn't az(AZ) format.");return t.toLowerCase().split("").map(t=>t.charCodeAt(0)-97).reverse().map((t,e)=>(t+1)*26**e).reduce((t,e)=>t+e)-1},t.asJpy=function(t){return j.isEmpty(t)?"":n(Math.floor(t),"¥")},t.asUsd=function(t){return j.isEmpty(t)?"":n(Number(t.toFixed(2)),"$")},t.asPercentage=function(t){if(j.isEmpty(t))return"";let e=(100*t).toFixed(2);for(;e.endsWith("0");)e=e.substring(0,e.length-1);return e.endsWith(".")&&(e=e.substring(0,e.length-1)),e+"%"},t.is_yyyy=function(t){return!!t?.match(/^[1-9]\d{3}$/)},t.is_yyyyMM=function(t){return!!t?.match(/^[1-9]\d{3}(0[1-9]|1[0-2])$/)},t.is_yyyyMMdd=function(t){return!!t?.match(/^[1-9]\d{3}(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|[3][0-1])$/)},t.is_yyyyMMddhh=function(t){return!!t?.match(/^[1-9]\d{3}(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|[3][0-1])([01]\d|2[0-3])$/)},t.is_yyyyMMddhhmm=function(t){return!!t?.match(/^[1-9]\d{3}(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|[3][0-1])([01]\d|2[0-3])[0-5]\d$/)},t.is_yyyyMMddhhmmss=function(t){return!!t?.match(/^[1-9]\d{3}(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|[3][0-1])([01]\d|2[0-3])[0-5]\d[0-5]\d$/)}}(w||(w={})),function(t){function e(t,e=!0){const n=Math.floor(t.length*Math.random()),r=t[n];return e&&t.splice(n,1),r}t.eq=function(t,e,n={}){const{sort:r,useStrictEqual:o}=Object.assign({sort:!0,useStrictEqual:!0},n);if(t&&!e||!t&&e)return!1;if(!t)return!0;if(t.length!==e.length)return!1;const i=r?[...t].sort():t,s=r?[...e].sort():e;return i.every((t,e)=>o?t===s[e]:t==s[e])},t.distinct=function(t,e){if(!t||0===t.length)return[];if(e?.k)return Array.from(p(t,t=>t[e.k]).values()).map(t=>e?.takeLast?t.pop():t.shift());const n=e?.takeLast?[...t].reverse():[...t],r=e?.predicate??((t,e)=>t==e),o=[n.shift()];return n.forEach(t=>o.some(e=>r(t,e))?{}:o.push(t)),o},t.chop=function(t,e){return[...Array(Math.ceil(t.length/e)).keys()].map(n=>{let r=(n+1)*e;return r>t.length&&(r=t.length),t.slice(n*e,r)})},t.remove=function(t,e){const n=t.indexOf(e);-1!==n&&t.splice(n,1)},t.randomPick=e,t.shuffle=function(t){const n=[...t];return d(t.length).map(t=>e(n))},t.takeOut=function(t,e){const n=[];for(let r=t.length-1;r>=0;r--)e(t[r],r)&&(n.unshift(t[r]),t.splice(r,1));return n}}(O||(O={})),function(t){function e(t){return Math.floor(t/100)}t.isHttpSuccess=function(t){return 2===e(t)},t.statusCategoryOf=e,t.concatParamsWithEncoding=function(t,e){if(!e||0===Object.keys(e).length)return t;const n=Object.entries(e).flatMap(t=>Array.isArray(t[1])?t[1].map(e=>[t[0],e]):[t]);let r=t?t+"?":"";for(var o of n)r+=o[0]+"="+encodeURIComponent(o[1])+"&";return r.substring(0,r.length-1)},t.normalizeHeaders=function(t){return t?Object.entries(t).reduce((t,e)=>(t[e[0].toLowerCase()]=e[1],t),{}):{}}}(S||(S={}));const v=100;function P(t){let e=0;const n=t?.timeoutSec??30;return(t,r,o)=>{const i=o.value;o.value=async function(...t){const r=Date.now()+1e3*n;for(;e>0;){if(r<=Date.now())throw new a(v,"An exclusive process to execute was already running by other request.");await y(1)}try{e++;const n=i.apply(this,t);return n instanceof Promise?await n:n}finally{e--}}}}return i})());
|
package/dist/types.d.ts
DELETED
|
@@ -1,285 +0,0 @@
|
|
|
1
|
-
declare module "const/types" {
|
|
2
|
-
export type IndexSignature = string | number | symbol;
|
|
3
|
-
export type NormalRecord = Record<IndexSignature, any>;
|
|
4
|
-
export type MaybeArray<T> = T | T[];
|
|
5
|
-
export type Loggable = {
|
|
6
|
-
log: (msg: any) => void;
|
|
7
|
-
warn: (msg: any) => void;
|
|
8
|
-
error: (msg: any) => void;
|
|
9
|
-
};
|
|
10
|
-
export type Unique<T = number> = {
|
|
11
|
-
id: T;
|
|
12
|
-
};
|
|
13
|
-
export type IdName<T = number> = {
|
|
14
|
-
name: string;
|
|
15
|
-
} & Unique<T>;
|
|
16
|
-
export enum Type {
|
|
17
|
-
string = "string",
|
|
18
|
-
number = "number",
|
|
19
|
-
bigint = "bigint",
|
|
20
|
-
boolean = "boolean",
|
|
21
|
-
symbol = "symbol",
|
|
22
|
-
object = "object",
|
|
23
|
-
undefined = "undefined",
|
|
24
|
-
null = "null"
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
declare module "const/time-unit" {
|
|
28
|
-
export enum TimeUnit {
|
|
29
|
-
Year = 1,
|
|
30
|
-
Month = 2,
|
|
31
|
-
Day = 3,
|
|
32
|
-
Hour = 4,
|
|
33
|
-
Min = 5,
|
|
34
|
-
Sec = 6,
|
|
35
|
-
Msec = 7
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
declare module "const/gender" {
|
|
39
|
-
export enum Gender {
|
|
40
|
-
Male = 0,
|
|
41
|
-
Female = 1
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
declare module "const/http-method" {
|
|
45
|
-
export enum HttpMethod {
|
|
46
|
-
Get = "GET",
|
|
47
|
-
Put = "PUT",
|
|
48
|
-
Post = "POST",
|
|
49
|
-
Delete = "DELETE",
|
|
50
|
-
Patch = "PATCH",
|
|
51
|
-
Connect = "CONNECT"
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
declare module "const/ccy" {
|
|
55
|
-
export interface Ccy {
|
|
56
|
-
symbol: t_ccySymbol;
|
|
57
|
-
crossUsd: string;
|
|
58
|
-
}
|
|
59
|
-
export type t_ccySymbol = keyof (typeof currencies);
|
|
60
|
-
const currencies: {
|
|
61
|
-
jpy: Ccy;
|
|
62
|
-
usd: Ccy;
|
|
63
|
-
gbp: Ccy;
|
|
64
|
-
eur: Ccy;
|
|
65
|
-
cad: Ccy;
|
|
66
|
-
aud: Ccy;
|
|
67
|
-
};
|
|
68
|
-
export const s_ccy: {
|
|
69
|
-
[k in t_ccySymbol]: Readonly<Ccy>;
|
|
70
|
-
};
|
|
71
|
-
export function resolveCcy(str: string): Ccy;
|
|
72
|
-
}
|
|
73
|
-
declare module "obj/xjs-err" {
|
|
74
|
-
export class XjsErr extends Error {
|
|
75
|
-
code: number;
|
|
76
|
-
origin?: any;
|
|
77
|
-
constructor(code: number, msg: string, origin?: any);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
declare module "func/u" {
|
|
81
|
-
import { Loggable } from "const/types";
|
|
82
|
-
export function getJSTDate(d?: Date): Date;
|
|
83
|
-
export function delay(sec: number): Promise<void>;
|
|
84
|
-
export function int2array(size: number): number[];
|
|
85
|
-
export function array2map<K, T>(array: T[], keyGen: (e: T) => K): Map<K, T[]>;
|
|
86
|
-
export function bitor(...bit: number[]): number;
|
|
87
|
-
export interface RetryOption<T = void | Promise<void>> {
|
|
88
|
-
count?: number;
|
|
89
|
-
logger?: Loggable;
|
|
90
|
-
errorCriterion?: (e: any) => boolean;
|
|
91
|
-
intervalPredicate?: () => T;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* runs callback with customizable retry.
|
|
95
|
-
* @param cb callback to be retried.
|
|
96
|
-
* @param op.count number of retries. default is 1.
|
|
97
|
-
* @param op.logger logger used for exceptions while retrying the process. default is `console` object.
|
|
98
|
-
* @param op.errorCriterion distinguish whether retry is required form exceptions. default is none. (i.e. allways required.)
|
|
99
|
-
* @param op.intervalPredicate predicate that runs between callbacks when retrying.
|
|
100
|
-
*/
|
|
101
|
-
export function retry<T>(cb: () => T, op?: RetryOption<void>): T;
|
|
102
|
-
export function retry<T>(cb: () => T, op?: RetryOption<Promise<void>>): Promise<T>;
|
|
103
|
-
export function retry<T>(cb: () => Promise<T>, op?: RetryOption<void>): Promise<T>;
|
|
104
|
-
export function retry<T>(cb: () => Promise<T>, op?: RetryOption<Promise<void>>): Promise<T>;
|
|
105
|
-
}
|
|
106
|
-
declare module "func/u-type" {
|
|
107
|
-
import { MaybeArray, Type } from "const/types";
|
|
108
|
-
export namespace UType {
|
|
109
|
-
function isDefined(v: any): boolean;
|
|
110
|
-
function isEmpty(v: any): boolean;
|
|
111
|
-
function isString(v: any): v is string;
|
|
112
|
-
function isNumber(v: any): v is number;
|
|
113
|
-
function isBigint(v: any): v is bigint;
|
|
114
|
-
function isBoolean(v: any): v is boolean;
|
|
115
|
-
function isSymbol(v: any): v is symbol;
|
|
116
|
-
function isObject(v: any): v is object;
|
|
117
|
-
function isArray(v: any, t: Type.string): v is string[];
|
|
118
|
-
function isArray(v: any, t: Type.number): v is number[];
|
|
119
|
-
function isArray(v: any, t: Type.bigint): v is bigint[];
|
|
120
|
-
function isArray(v: any, t: Type.boolean): v is boolean[];
|
|
121
|
-
function isArray(v: any, t: Type.symbol): v is symbol[];
|
|
122
|
-
function isArray(v: any, t: Type.object): v is object[];
|
|
123
|
-
function isArray(v: any): v is any[];
|
|
124
|
-
/**
|
|
125
|
-
* validate properties which attached decorators in {@link DType}.
|
|
126
|
-
* @param o object to be validated.
|
|
127
|
-
* @returns invalid property keys. returns an empty array if `o` is valid.
|
|
128
|
-
*/
|
|
129
|
-
function validate(o: any): string[];
|
|
130
|
-
function takeAsArray<T>(v: MaybeArray<T>): T[];
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
declare module "func/decorator/d-type" {
|
|
134
|
-
import { Type } from "const/types";
|
|
135
|
-
export const smbl_tm: unique symbol;
|
|
136
|
-
export interface TypeDesc {
|
|
137
|
-
t?: Type;
|
|
138
|
-
req?: boolean;
|
|
139
|
-
ary?: TypeDesc;
|
|
140
|
-
rec?: boolean;
|
|
141
|
-
}
|
|
142
|
-
export interface TypeMap {
|
|
143
|
-
[k: string]: TypeDesc;
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* decorators to be validated by {@link UType.validate},
|
|
147
|
-
* and to be cropped by {@link UObj.crop}.
|
|
148
|
-
*/
|
|
149
|
-
export namespace DType {
|
|
150
|
-
function string(target: Object, propKey: string): void;
|
|
151
|
-
function number(target: Object, propKey: string): void;
|
|
152
|
-
function boolean(target: Object, propKey: string): void;
|
|
153
|
-
function required(target: Object, propKey: string): void;
|
|
154
|
-
function array(elmDesc?: TypeDesc): (target: Object, propKey: string) => void;
|
|
155
|
-
function recursive(target: Object, propKey: string): void;
|
|
156
|
-
function keep(target: Object, propKey: string): void;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
declare module "func/u-obj" {
|
|
160
|
-
import { NormalRecord } from "const/types";
|
|
161
|
-
export namespace UObj {
|
|
162
|
-
/**
|
|
163
|
-
* assign properties to the object with specified property keys.
|
|
164
|
-
* @param t target object.
|
|
165
|
-
* @param s source object.
|
|
166
|
-
* @param keys property keys which are copied from source object. if omit this, all keys in source object is applied.
|
|
167
|
-
* @param keepDtypeClass if true, class which has properties decorated with {@link DType} in target object is kept and that is assigned properties recursively.
|
|
168
|
-
*/
|
|
169
|
-
function assignProperties<T extends NormalRecord, S extends NormalRecord>(t: T, s: S, keys?: (keyof S)[], keepDtypeClass?: boolean): T & Partial<S>;
|
|
170
|
-
/**
|
|
171
|
-
* crop properties of the object. the properties is removed with `delete` operator.
|
|
172
|
-
* @param o object which properties is removed.
|
|
173
|
-
* @param keys property names to be remained. if omit this, it removes the properties other than properties decorated {@link DType}.
|
|
174
|
-
* @param exclusive if true, it removes `keys` instead of remaining it.
|
|
175
|
-
*/
|
|
176
|
-
function crop<T extends NormalRecord>(o: T, keys?: (keyof T)[], exclusive?: boolean): Partial<T>;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
declare module "func/u-string" {
|
|
180
|
-
import { TimeUnit } from "const/time-unit";
|
|
181
|
-
export namespace UString {
|
|
182
|
-
function eq(s1: string, s2: string): boolean;
|
|
183
|
-
function repeat(token: string, mlt: number): string;
|
|
184
|
-
/**
|
|
185
|
-
* generate date time number as fixed length (depends on `unit`) string without separator charactor.
|
|
186
|
-
* For example, `2025-06-08T10:15:06.366Z` is to be `20250608101506366`.
|
|
187
|
-
* @param op.date Date object refered by this. default is `new Date()`.
|
|
188
|
-
* @param op.unit time unit. default is secound.
|
|
189
|
-
*/
|
|
190
|
-
function simpleTime(op?: {
|
|
191
|
-
date?: Date;
|
|
192
|
-
unit?: TimeUnit;
|
|
193
|
-
}): string;
|
|
194
|
-
function generateRandomString(len: number): string;
|
|
195
|
-
function idx2az(idx: number): string;
|
|
196
|
-
function az2idx(az: string): number;
|
|
197
|
-
function asJpy(amount: number): string;
|
|
198
|
-
function asUsd(amount: number): string;
|
|
199
|
-
function asPercentage(amount: number): string;
|
|
200
|
-
function is_yyyy(v: string): boolean;
|
|
201
|
-
function is_yyyyMM(v: string): boolean;
|
|
202
|
-
function is_yyyyMMdd(v: string): boolean;
|
|
203
|
-
function is_yyyyMMddhh(v: string): boolean;
|
|
204
|
-
function is_yyyyMMddhhmm(v: string): boolean;
|
|
205
|
-
function is_yyyyMMddhhmmss(v: string): boolean;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
declare module "func/u-array" {
|
|
209
|
-
export namespace UArray {
|
|
210
|
-
/**
|
|
211
|
-
* compares two arrays to valuate equality.
|
|
212
|
-
* if one side is null or undefined, it returns true when other side is the same.
|
|
213
|
-
* @param v1 it uses equal operator for comparing elements, so applying object element is not recommended.
|
|
214
|
-
* @param v2 same as v1.
|
|
215
|
-
* @param sort it uses {@link Array#sort} on v1 and v2 if true. default is true.
|
|
216
|
-
* @param useStrictEqual it uses `===` operator for compareing elements if true, otherwise using `==` operator. default is true.
|
|
217
|
-
*/
|
|
218
|
-
function eq(v1: any[], v2: any[], op: {
|
|
219
|
-
sort?: boolean;
|
|
220
|
-
useStrictEqual: false;
|
|
221
|
-
}): boolean;
|
|
222
|
-
function eq<T>(v1: T[], v2: T[], op: {
|
|
223
|
-
sort?: boolean;
|
|
224
|
-
useStrictEqual: true;
|
|
225
|
-
}): boolean;
|
|
226
|
-
function eq<T>(v1: T[], v2: T[], op: {
|
|
227
|
-
sort?: boolean;
|
|
228
|
-
}): boolean;
|
|
229
|
-
function eq<T>(v1: T[], v2: T[]): boolean;
|
|
230
|
-
/**
|
|
231
|
-
* returns array which is removed duplicate of elements.
|
|
232
|
-
* this doesn't mutate the param.
|
|
233
|
-
*/
|
|
234
|
-
function distinct<T>(array: T[]): T[];
|
|
235
|
-
function distinct<T>(array: T[], op: {
|
|
236
|
-
k: keyof T;
|
|
237
|
-
takeLast?: boolean;
|
|
238
|
-
}): T[];
|
|
239
|
-
function distinct<T>(array: T[], op: {
|
|
240
|
-
predicate: (v1: T, v2: T) => boolean;
|
|
241
|
-
takeLast?: boolean;
|
|
242
|
-
}): T[];
|
|
243
|
-
function chop<T>(array: T[], len: number): T[][];
|
|
244
|
-
function remove<T>(array: T[], v: T): void;
|
|
245
|
-
function randomPick<T>(array: T[], takeout?: boolean): T;
|
|
246
|
-
function shuffle<T>(array: T[]): T[];
|
|
247
|
-
function takeOut<T>(array: T[], filter: (v: T, i?: number) => boolean): T[];
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
declare module "func/u-http" {
|
|
251
|
-
export namespace UHttp {
|
|
252
|
-
function isHttpSuccess(statusCode: number): boolean;
|
|
253
|
-
function statusCategoryOf(statusCode: number): number;
|
|
254
|
-
function concatParamsWithEncoding(end: string, params: {
|
|
255
|
-
[k: string]: string | string[];
|
|
256
|
-
}): string;
|
|
257
|
-
/** normalize object keys to lower case. */
|
|
258
|
-
function normalizeHeaders(headers: Record<string, any>): Record<string, any>;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
declare module "func/decorator/transaction" {
|
|
262
|
-
/**
|
|
263
|
-
* applies transation to the method. note that the method must return a Promise.
|
|
264
|
-
* @param op.timeoutSec default is `30`.
|
|
265
|
-
*/
|
|
266
|
-
export function transaction(op?: {
|
|
267
|
-
timeoutSec?: number;
|
|
268
|
-
}): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
269
|
-
}
|
|
270
|
-
declare module "xjs-common" {
|
|
271
|
-
export * from "const/types";
|
|
272
|
-
export * from "const/time-unit";
|
|
273
|
-
export * from "const/gender";
|
|
274
|
-
export * from "const/http-method";
|
|
275
|
-
export * from "const/ccy";
|
|
276
|
-
export * from "func/u";
|
|
277
|
-
export * from "func/u-obj";
|
|
278
|
-
export * from "func/u-string";
|
|
279
|
-
export * from "func/u-array";
|
|
280
|
-
export * from "func/u-http";
|
|
281
|
-
export * from "func/u-type";
|
|
282
|
-
export * from "func/decorator/transaction";
|
|
283
|
-
export { DType } from "func/decorator/d-type";
|
|
284
|
-
export * from "obj/xjs-err";
|
|
285
|
-
}
|