@cclr/lang 0.1.4 → 0.1.6

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/lib/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";const e=Function.prototype.call.bind(Object.prototype.hasOwnProperty),t=Function.prototype.call.bind(Object.prototype.toString),r={boolean:"boolean",undefined:"undefined",number:"number",string:"string",symbol:"symbol",null:"null","[object Object]":"object","[object Function]":"function","[object RegExp]":"regexp","[object Array]":"array","[object Date]":"date","[object Error]":"error","[object Blob]":"blob","[object File]":"file","[object ArrayBuffer]":"arrayBuffer"};function n(e){return r[typeof e]||r[t(e)]||(e?"object":"null")}function o(e){return null===e}function i(e){return void 0===e}function s(e){return o(e)||i(e)}function c(e){return u(e)&&Object.getPrototypeOf(e)===Object.prototype}function u(e){return"object"===n(e)}function l(e){return Array.isArray(e)}const p=()=>{},b={string:"",number:0,boolean:!1,undefined:void 0,null:null,object:{},array:[],function:p,regexp:/(?:)/},f=(e,t)=>{if(n(e)!==n(t))return!1;if(l(e))return e.length===t.length&&e.every(((e,r)=>f(e,t[r])));if(u(e)){const r=Object.keys(e),n=Object.keys(t);return r.length===n.length&&r.every((r=>f(e[r],t[r])))}return e===t},a=(e,[t,...r])=>(e=e[t],r.length&&e?a(e,r):e);var y=Object.freeze({__proto__:null,extend:(e,t)=>(u(e)&&Object.keys(t).forEach((r=>{e[r]=t[r]})),e),filter:(e,t=s)=>{const r={};return c(e)&&Object.entries(e).forEach((([n,o])=>{t(e[n],n)&&(r[n]=o)})),r},forEach:(e,t)=>{Object.keys(e).forEach((r=>{t(e[r],r)}))},format:(e,t)=>{for(const r of t){const[t,o,i]=r;n(e[t])!==o&&(3!==r.length?e[t]=b[o]:e[t]=i)}return e},pick:(e,t)=>t.reduce(((t,r)=>(r in e&&(t[r]=e[r]),t)),{})});const j=(e,[t,...r],n)=>{if(e=e[t]=r.length?e[t]||{}:n,r.length){if(!c(e)||l(e))throw new Error(`path node ['.${t}'] must be plain object {}!`);j(e,r,n)}};exports.VAL_TYPE=r,exports.defaultValue=b,exports.get=(e,t,r)=>{const n=a(e||{},t.split("."));return i(n)||o(n)?r:n},exports.getParamType=n,exports.hasOwn=e,exports.isArray=l,exports.isBoolean=function(e){return"boolean"===n(e)},exports.isEmpty=e=>!!s(e)||(u(e)?Object.keys(e).length<=0:!String(e)),exports.isEqual=f,exports.isFunction=function(e){return"function"===n(e)},exports.isNull=o,exports.isNumber=e=>"number"===n(e)&&isFinite(e),exports.isObject=u,exports.isPlainObject=c,exports.isString=function(e){return"string"===n(e)},exports.isSymbol=function(e){return"symbol"===n(e)},exports.isType=function(e,t){return n(e)===t},exports.isUndefined=i,exports.isUndefinedOrNull=s,exports.noop=p,exports.obj=y,exports.set=(e,t,r)=>(j(e=e||{},t.split("."),r),e),exports.toString=t;
1
+ "use strict";var t=Function.prototype.call.bind(Object.prototype.hasOwnProperty),r=Function.prototype.call.bind(Object.prototype.toString),n={boolean:"boolean",undefined:"undefined",number:"number",string:"string",symbol:"symbol",null:"null","[object Object]":"object","[object Function]":"function","[object RegExp]":"regexp","[object Array]":"array","[object Date]":"date","[object Error]":"error","[object Blob]":"blob","[object File]":"file","[object ArrayBuffer]":"arrayBuffer"};function e(t){return n[typeof t]||n[r(t)]||(t?"object":"null")}function o(t){return null===t}function i(t){return void 0===t}function u(t){return o(t)||i(t)}function c(t){return l(t)&&Object.getPrototypeOf(t)===Object.prototype}function l(t){return"object"===e(t)}function a(t){return Array.isArray(t)}var f=function(){},s={string:"",number:0,boolean:!1,undefined:void 0,null:null,object:{},array:[],function:f,regexp:/(?:)/},b=function(t,r){if(e(t)!==e(r))return!1;if(a(t))return t.length===r.length&&t.every((function(t,n){return b(t,r[n])}));if(l(t)){var n=Object.keys(t),o=Object.keys(r);return n.length===o.length&&n.every((function(n){return b(t[n],r[n])}))}return t===r};function y(t,r){(null==r||r>t.length)&&(r=t.length);for(var n=0,e=Array(r);n<r;n++)e[n]=t[n];return e}function p(t){if(Array.isArray(t))return t}function d(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function h(t,r){return p(t)||function(t,r){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var e,o,i,u,c=[],l=!0,a=!1;try{if(i=(n=n.call(t)).next,0===r){if(Object(n)!==n)return;l=!1}else for(;!(l=(e=i.call(n)).done)&&(c.push(e.value),c.length!==r);l=!0);}catch(t){a=!0,o=t}finally{try{if(!l&&null!=n.return&&(u=n.return(),Object(u)!==u))return}finally{if(a)throw o}}return c}}(t,r)||m(t,r)||d()}function j(t){return p(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||m(t)||d()}function m(t,r){if(t){if("string"==typeof t)return y(t,r);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?y(t,r):void 0}}var v=function(t,r){var n=j(r),e=n[0],o=n.slice(1);return t=t[e],o.length&&t?v(t,o):t},g=Object.freeze({__proto__:null,extend:function(t,r){return l(t)&&Object.keys(r).forEach((function(n){t[n]=r[n]})),t},filter:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:u,n={};return c(t)&&Object.entries(t).forEach((function(e){var o=h(e,2),i=o[0],u=o[1];r(t[i],i)&&(n[i]=u)})),n},forEach:function(t,r){Object.keys(t).forEach((function(n){r(t[n],n)}))},format:function(t,r){var n,o=function(t,r){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=m(t))||r){n&&(t=n);var e=0,o=function(){};return{s:o,n:function(){return e>=t.length?{done:!0}:{done:!1,value:t[e++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,u=!0,c=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return u=t.done,t},e:function(t){c=!0,i=t},f:function(){try{u||null==n.return||n.return()}finally{if(c)throw i}}}}(r);try{for(o.s();!(n=o.n()).done;){var i=n.value,u=h(i,3),c=u[0],l=u[1],a=u[2];e(t[c])!==l&&(3!==i.length?t[c]=s[l]:t[c]=a)}}catch(t){o.e(t)}finally{o.f()}return t},pick:function(t,r){return r.reduce((function(r,n){return n in t&&(r[n]=t[n]),r}),{})}}),x=function(t,r,n){var e=j(r),o=e[0],i=e.slice(1);if(t=t[o]=i.length?t[o]||{}:n,i.length){if(!c(t)||a(t))throw new Error("path node ['.".concat(o,"'] must be plain object {}!"));x(t,i,n)}};exports.VAL_TYPE=n,exports.defaultValue=s,exports.get=function(t,r,n){var e=v(t||{},r.split("."));return i(e)||o(e)?n:e},exports.getParamType=e,exports.hasOwn=t,exports.isArray=a,exports.isBoolean=function(t){return"boolean"===e(t)},exports.isEmpty=function(t){return!!u(t)||(l(t)?Object.keys(t).length<=0:!String(t))},exports.isEqual=b,exports.isFunction=function(t){return"function"===e(t)},exports.isNull=o,exports.isNumber=function(t){return"number"===e(t)&&isFinite(t)},exports.isObject=l,exports.isPlainObject=c,exports.isString=function(t){return"string"===e(t)},exports.isSymbol=function(t){return"symbol"===e(t)},exports.isType=function(t,r){return e(t)===r},exports.isUndefined=i,exports.isUndefinedOrNull=u,exports.noop=f,exports.obj=g,exports.set=function(t,r,n){return x(t=t||{},r.split("."),n),t},exports.toString=r;
package/lib/esm/index.js CHANGED
@@ -1 +1 @@
1
- const t=Function.prototype.call.bind(Object.prototype.hasOwnProperty),e=Function.prototype.call.bind(Object.prototype.toString),n={boolean:"boolean",undefined:"undefined",number:"number",string:"string",symbol:"symbol",null:"null","[object Object]":"object","[object Function]":"function","[object RegExp]":"regexp","[object Array]":"array","[object Date]":"date","[object Error]":"error","[object Blob]":"blob","[object File]":"file","[object ArrayBuffer]":"arrayBuffer"};function r(t){return n[typeof t]||n[e(t)]||(t?"object":"null")}function o(t,e){return r(t)===e}function c(t){return"string"===r(t)}const u=t=>"number"===r(t)&&isFinite(t);function i(t){return"boolean"===r(t)}function b(t){return"symbol"===r(t)}function l(t){return null===t}function f(t){return void 0===t}function s(t){return l(t)||f(t)}function a(t){return"function"===r(t)}function j(t){return y(t)&&Object.getPrototypeOf(t)===Object.prototype}function y(t){return"object"===r(t)}function p(t){return Array.isArray(t)}const g=()=>{},h={string:"",number:0,boolean:!1,undefined:void 0,null:null,object:{},array:[],function:g,regexp:/(?:)/},d=t=>!!s(t)||(y(t)?Object.keys(t).length<=0:!String(t)),O=(t,e)=>{if(r(t)!==r(e))return!1;if(p(t))return t.length===e.length&&t.every(((t,n)=>O(t,e[n])));if(y(t)){const n=Object.keys(t),r=Object.keys(e);return n.length===r.length&&n.every((n=>O(t[n],e[n])))}return t===e},m=(t,[e,...n])=>(t=t[e],n.length&&t?m(t,n):t),E=(t,e,n)=>{const r=m(t||{},e.split("."));return f(r)||l(r)?n:r};var k=Object.freeze({__proto__:null,extend:(t,e)=>(y(t)&&Object.keys(e).forEach((n=>{t[n]=e[n]})),t),filter:(t,e=s)=>{const n={};return j(t)&&Object.entries(t).forEach((([r,o])=>{e(t[r],r)&&(n[r]=o)})),n},forEach:(t,e)=>{Object.keys(t).forEach((n=>{e(t[n],n)}))},format:(t,e)=>{for(const n of e){const[e,o,c]=n;r(t[e])!==o&&(3!==n.length?t[e]=h[o]:t[e]=c)}return t},pick:(t,e)=>e.reduce(((e,n)=>(n in t&&(e[n]=t[n]),e)),{})});const v=(t,[e,...n],r)=>{if(t=t[e]=n.length?t[e]||{}:r,n.length){if(!j(t)||p(t))throw new Error(`path node ['.${e}'] must be plain object {}!`);v(t,n,r)}},x=(t,e,n)=>(v(t=t||{},e.split("."),n),t);export{n as VAL_TYPE,h as defaultValue,E as get,r as getParamType,t as hasOwn,p as isArray,i as isBoolean,d as isEmpty,O as isEqual,a as isFunction,l as isNull,u as isNumber,y as isObject,j as isPlainObject,c as isString,b as isSymbol,o as isType,f as isUndefined,s as isUndefinedOrNull,g as noop,k as obj,x as set,e as toString};
1
+ var n=Function.prototype.call.bind(Object.prototype.hasOwnProperty),t=Function.prototype.call.bind(Object.prototype.toString),r={boolean:"boolean",undefined:"undefined",number:"number",string:"string",symbol:"symbol",null:"null","[object Object]":"object","[object Function]":"function","[object RegExp]":"regexp","[object Array]":"array","[object Date]":"date","[object Error]":"error","[object Blob]":"blob","[object File]":"file","[object ArrayBuffer]":"arrayBuffer"};function e(n){return r[typeof n]||r[t(n)]||(n?"object":"null")}function o(n,t){return e(n)===t}function u(n){return"string"===e(n)}var i=function(n){return"number"===e(n)&&isFinite(n)};function c(n){return"boolean"===e(n)}function f(n){return"symbol"===e(n)}function l(n){return null===n}function a(n){return void 0===n}function b(n){return l(n)||a(n)}function y(n){return"function"===e(n)}function s(n){return d(n)&&Object.getPrototypeOf(n)===Object.prototype}function d(n){return"object"===e(n)}function p(n){return Array.isArray(n)}var h=function(){},v={string:"",number:0,boolean:!1,undefined:void 0,null:null,object:{},array:[],function:h,regexp:/(?:)/},j=function(n){return!!b(n)||(d(n)?Object.keys(n).length<=0:!String(n))},m=function(n,t){if(e(n)!==e(t))return!1;if(p(n))return n.length===t.length&&n.every((function(n,r){return m(n,t[r])}));if(d(n)){var r=Object.keys(n),o=Object.keys(t);return r.length===o.length&&r.every((function(r){return m(n[r],t[r])}))}return n===t};function g(n,t){(null==t||t>n.length)&&(t=n.length);for(var r=0,e=Array(t);r<t;r++)e[r]=n[r];return e}function O(n){if(Array.isArray(n))return n}function A(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function S(n,t){return O(n)||function(n,t){var r=null==n?null:"undefined"!=typeof Symbol&&n[Symbol.iterator]||n["@@iterator"];if(null!=r){var e,o,u,i,c=[],f=!0,l=!1;try{if(u=(r=r.call(n)).next,0===t){if(Object(r)!==r)return;f=!1}else for(;!(f=(e=u.call(r)).done)&&(c.push(e.value),c.length!==t);f=!0);}catch(n){l=!0,o=n}finally{try{if(!f&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(l)throw o}}return c}}(n,t)||E(n,t)||A()}function w(n){return O(n)||function(n){if("undefined"!=typeof Symbol&&null!=n[Symbol.iterator]||null!=n["@@iterator"])return Array.from(n)}(n)||E(n)||A()}function E(n,t){if(n){if("string"==typeof n)return g(n,t);var r={}.toString.call(n).slice(8,-1);return"Object"===r&&n.constructor&&(r=n.constructor.name),"Map"===r||"Set"===r?Array.from(n):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?g(n,t):void 0}}var x=function(n,t){var r=w(t),e=r[0],o=r.slice(1);return n=n[e],o.length&&n?x(n,o):n},k=function(n,t,r){var e=x(n||{},t.split("."));return a(e)||l(e)?r:e},F=Object.freeze({__proto__:null,extend:function(n,t){return d(n)&&Object.keys(t).forEach((function(r){n[r]=t[r]})),n},filter:function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:b,r={};return s(n)&&Object.entries(n).forEach((function(e){var o=S(e,2),u=o[0],i=o[1];t(n[u],u)&&(r[u]=i)})),r},forEach:function(n,t){Object.keys(n).forEach((function(r){t(n[r],r)}))},format:function(n,t){var r,o=function(n,t){var r="undefined"!=typeof Symbol&&n[Symbol.iterator]||n["@@iterator"];if(!r){if(Array.isArray(n)||(r=E(n))||t){r&&(n=r);var e=0,o=function(){};return{s:o,n:function(){return e>=n.length?{done:!0}:{done:!1,value:n[e++]}},e:function(n){throw n},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var u,i=!0,c=!1;return{s:function(){r=r.call(n)},n:function(){var n=r.next();return i=n.done,n},e:function(n){c=!0,u=n},f:function(){try{i||null==r.return||r.return()}finally{if(c)throw u}}}}(t);try{for(o.s();!(r=o.n()).done;){var u=r.value,i=S(u,3),c=i[0],f=i[1],l=i[2];e(n[c])!==f&&(3!==u.length?n[c]=v[f]:n[c]=l)}}catch(n){o.e(n)}finally{o.f()}return n},pick:function(n,t){return t.reduce((function(t,r){return r in n&&(t[r]=n[r]),t}),{})}}),I=function(n,t,r){var e=w(t),o=e[0],u=e.slice(1);if(n=n[o]=u.length?n[o]||{}:r,u.length){if(!s(n)||p(n))throw new Error("path node ['.".concat(o,"'] must be plain object {}!"));I(n,u,r)}},_=function(n,t,r){return I(n=n||{},t.split("."),r),n};export{r as VAL_TYPE,v as defaultValue,k as get,e as getParamType,n as hasOwn,p as isArray,c as isBoolean,j as isEmpty,m as isEqual,y as isFunction,l as isNull,i as isNumber,d as isObject,s as isPlainObject,u as isString,f as isSymbol,o as isType,a as isUndefined,b as isUndefinedOrNull,h as noop,F as obj,_ as set,t as toString};
@@ -1,7 +1,7 @@
1
1
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2
- type TAny$1 = any;
3
- type TPlainObject = Record<string, TAny$1>;
4
- type TPlainFunction = (...args: TAny$1[]) => TAny$1;
2
+ type TAny = any;
3
+ type TPlainObject = Record<string, TAny>;
4
+ type TPlainFunction = (...args: TAny[]) => TAny;
5
5
 
6
6
  declare const VAL_TYPE: {
7
7
  readonly boolean: "boolean";
@@ -46,10 +46,7 @@ declare function isFunction(b: unknown): b is TPlainFunction;
46
46
  */
47
47
  declare function isPlainObject(b: unknown): b is Record<string, unknown>;
48
48
  declare function isObject(b: unknown): b is Record<string, unknown>;
49
- declare function isArray(a: unknown): a is TAny$1[];
50
-
51
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
52
- type TAny = any;
49
+ declare function isArray(a: unknown): a is TAny[];
53
50
 
54
51
  /**
55
52
  * () => {};
@@ -93,7 +90,7 @@ declare const isEmpty: (v: unknown) => boolean;
93
90
  * @param targetValue
94
91
  * @returns boolean
95
92
  */
96
- declare const isEqual: (sourceValue: TAny$1, targetValue: TAny$1) => any;
93
+ declare const isEqual: (sourceValue: TAny, targetValue: TAny) => any;
97
94
 
98
95
  /**
99
96
  * Check if an object has a property.
@@ -126,7 +123,7 @@ declare const extend: <T extends object, J extends object>(sourceObj: T & Partia
126
123
  * @param filter
127
124
  * @returns
128
125
  */
129
- declare const filter: <T extends object, K extends keyof T>(sourceObj: T, filter?: (val: TAny$1, key: K) => boolean) => Partial<T>;
126
+ declare const filter: <T extends object, K extends keyof T>(sourceObj: T, filter?: (val: TAny, key: K) => boolean) => Partial<T>;
130
127
 
131
128
  /**
132
129
  * 遍历对象
@@ -142,7 +139,7 @@ declare const forEach: <T extends object, K extends keyof T>(obj: T, callback: (
142
139
  * @param formatOptionList [ key, 类型, 默认值? ]
143
140
  * @returns 格式化之后的原对象
144
141
  */
145
- declare const format: <T extends object, K extends keyof T>(object: T, formatOptionList: ([K, TVal, TAny$1] | [K, TVal])[]) => T;
142
+ declare const format: <T extends object, K extends keyof T = keyof T>(object: T, formatOptionList: ([K, TVal, TAny] | [K, TVal])[]) => T;
146
143
 
147
144
  /**
148
145
  * 对象挑选
@@ -169,4 +166,4 @@ declare namespace index {
169
166
  */
170
167
  declare const set: (source: object | null | undefined, path: string, value: any) => object;
171
168
 
172
- export { type TAny$1 as TAny, type TPlainFunction, type TPlainObject, type TVal, VAL_TYPE, defaultValue, get, getParamType, hasOwn, isArray, isBoolean, isEmpty, isEqual, isFunction, isNull, isNumber, isObject, isPlainObject, isString, isSymbol, isType, isUndefined, isUndefinedOrNull, noop, index as obj, set, toString };
169
+ export { type TAny, type TPlainFunction, type TPlainObject, type TVal, VAL_TYPE, defaultValue, get, getParamType, hasOwn, isArray, isBoolean, isEmpty, isEqual, isFunction, isNull, isNumber, isObject, isPlainObject, isString, isSymbol, isType, isUndefined, isUndefinedOrNull, noop, index as obj, set, toString };
package/package.json CHANGED
@@ -1,11 +1,10 @@
1
1
  {
2
2
  "name": "@cclr/lang",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "js语言基础工具",
5
5
  "author": "cclr <18843152354@163.com>",
6
6
  "homepage": "",
7
7
  "license": "MIT",
8
- "type": "module",
9
8
  "main": "lib/cjs/index.js",
10
9
  "module": "lib/esm/index.js",
11
10
  "types": "lib/type/index.d.ts",
@@ -28,5 +27,5 @@
28
27
  "g:test": "vitest run",
29
28
  "g:build": "ccf build"
30
29
  },
31
- "gitHead": "060e2cfbf8d6f933f431d54b528332f08af20b60"
30
+ "gitHead": "f7ad5275ae3c07cbf4597b6a38ba41362a27e4e1"
32
31
  }