@cclr/lang 0.1.27 → 0.1.29
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 +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/type/index.d.ts +25 -2
- package/package.json +4 -4
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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 f(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 f(t)&&Reflect.getPrototypeOf(t)===Object.prototype}function f(t){return"object"===e(t)}function l(t){return Array.isArray(t)}var a=function(){},s={string:"",number:0,boolean:!1,undefined:void 0,null:null,object:{},array:[],function:a,regexp:/(?:)/},b=function(t,r){if(e(t)!==e(r))return!1;if(l(t))return t.length===r.length&&t.every(function(t,n){return b(t,r[n])});if(f(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 p(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 y(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 y(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=[],f=!0,l=!1;try{if(i=(n=n.call(t)).next,0===r){if(Object(n)!==n)return;f=!1}else for(;!(f=(e=i.call(n)).done)&&(c.push(e.value),c.length!==r);f=!0);}catch(t){l=!0,o=t}finally{try{if(!f&&null!=n.return&&(u=n.return(),Object(u)!==u))return}finally{if(l)throw o}}return c}}(t,r)||g(t,r)||d()}function v(t){return y(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||g(t)||d()}function g(t,r){if(t){if("string"==typeof t)return p(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)?p(t,r):void 0}}var j=function(t,r){var n=v(r),e=n[0],o=p(n).slice(1);return t=t[e],o.length&&t?j(t,o):t},m=Object.freeze({__proto__:null,extend:function(t,r){var n=t||{};return c(r)&&Object.keys(r).forEach(function(t){n[t]=r[t]}),n},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=c(t)?t:{},i=function(t,r){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=g(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(i.s();!(n=i.n()).done;){var u=n.value,f=h(u,3),l=f[0],a=f[1],b=f[2];e(o[l])!==a&&(3!==u.length?o[l]=s[a]:o[l]=b)}}catch(t){i.e(t)}finally{i.f()}return o},omit:function(t,r){var n={};return c(t)&&Object.entries(t).forEach(function(t){var e=h(t,2),o=e[0],i=e[1];r.includes(o)||(n[o]=i)}),n},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=v(r),o=e[0],i=p(e).slice(1);if(t=t[o]=i.length?t[o]||{}:n,i.length){if(!c(t)||l(t))throw new Error("path node ['.".concat(o,"'] must be plain object {}!"));x(t,i,n)}};exports.VAL_TYPE=n,exports.defaultValue=s,exports.forEach=function(t,r,n){if(n)for(var e=t.length-1;e>=0;e--)r(t[e],e,t);else for(var o=0;o<t.length;o++)r(t[o],o,t)},exports.forEachReverse=function(t,r){for(var n=t.length-1;n>=0;n--)r(t[n],n,t)},exports.get=function(t,r,n){var e=j(t||{},r.split("."));return i(e)||o(e)?n:e},exports.getParamType=e,exports.hasOwn=t,exports.isArray=l,exports.isBoolean=function(t){return"boolean"===e(t)},exports.isEmpty=function(t){return!!u(t)||(f(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=f,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=a,exports.obj=m,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
|
-
var n=function(n,t,r){if(r)for(var e=n.length-1;e>=0;e--)t(n[e],e,n);else for(var o=0;o<n.length;o++)t(n[o],o,n)},t=function(n,t){for(var r=n.length-1;r>=0;r--)t(n[r],r,n)},r=Function.prototype.call.bind(Object.prototype.hasOwnProperty),e=Function.prototype.call.bind(Object.prototype.toString),o={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 u(n){return o[typeof n]||o[e(n)]||(n?"object":"null")}function i(n,t){return u(n)===t}function c(n){return"string"===u(n)}var f=function(n){return"number"===u(n)&&isFinite(n)};function a(n){return"boolean"===u(n)}function l(n){return"symbol"===u(n)}function b(n){return null===n}function y(n){return void 0===n}function s(n){return b(n)||y(n)}function v(n){return"function"===u(n)}function h(n){return d(n)&&
|
|
1
|
+
var n=function(n,t,r){if(r)for(var e=n.length-1;e>=0;e--)t(n[e],e,n);else for(var o=0;o<n.length;o++)t(n[o],o,n)},t=function(n,t){for(var r=n.length-1;r>=0;r--)t(n[r],r,n)},r=Function.prototype.call.bind(Object.prototype.hasOwnProperty),e=Function.prototype.call.bind(Object.prototype.toString),o={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 u(n){return o[typeof n]||o[e(n)]||(n?"object":"null")}function i(n,t){return u(n)===t}function c(n){return"string"===u(n)}var f=function(n){return"number"===u(n)&&isFinite(n)};function a(n){return"boolean"===u(n)}function l(n){return"symbol"===u(n)}function b(n){return null===n}function y(n){return void 0===n}function s(n){return b(n)||y(n)}function v(n){return"function"===u(n)}function h(n){return d(n)&&Reflect.getPrototypeOf(n)===Object.prototype}function d(n){return"object"===u(n)}function p(n){return Array.isArray(n)}var j=function(){},g={string:"",number:0,boolean:!1,undefined:void 0,null:null,object:{},array:[],function:j,regexp:/(?:)/},m=function(n){return!!s(n)||(d(n)?Object.keys(n).length<=0:!String(n))},O=function(n,t){if(u(n)!==u(t))return!1;if(p(n))return n.length===t.length&&n.every(function(n,r){return O(n,t[r])});if(d(n)){var r=Object.keys(n),e=Object.keys(t);return r.length===e.length&&r.every(function(r){return O(n[r],t[r])})}return n===t};function A(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 E(n){if(Array.isArray(n))return n}function S(){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 w(n,t){return E(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,a=!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){a=!0,o=n}finally{try{if(!f&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(a)throw o}}return c}}(n,t)||k(n,t)||S()}function x(n){return E(n)||function(n){if("undefined"!=typeof Symbol&&null!=n[Symbol.iterator]||null!=n["@@iterator"])return Array.from(n)}(n)||k(n)||S()}function k(n,t){if(n){if("string"==typeof n)return A(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)?A(n,t):void 0}}var F=function(n,t){var r=x(t),e=r[0],o=A(r).slice(1);return n=n[e],o.length&&n?F(n,o):n},I=function(n,t,r){var e=F(n||{},t.split("."));return y(e)||b(e)?r:e},_=Object.freeze({__proto__:null,extend:function(n,t){var r=n||{};return h(t)&&Object.keys(t).forEach(function(n){r[n]=t[n]}),r},filter:function(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:s,r={};return h(n)&&Object.entries(n).forEach(function(e){var o=w(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,e=h(n)?n:{},o=function(n,t){var r="undefined"!=typeof Symbol&&n[Symbol.iterator]||n["@@iterator"];if(!r){if(Array.isArray(n)||(r=k(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 i=r.value,c=w(i,3),f=c[0],a=c[1],l=c[2];u(e[f])!==a&&(3!==i.length?e[f]=g[a]:e[f]=l)}}catch(n){o.e(n)}finally{o.f()}return e},omit:function(n,t){var r={};return h(n)&&Object.entries(n).forEach(function(n){var e=w(n,2),o=e[0],u=e[1];t.includes(o)||(r[o]=u)}),r},pick:function(n,t){return t.reduce(function(t,r){return r in n&&(t[r]=n[r]),t},{})}}),B=function(n,t,r){var e=x(t),o=e[0],u=A(e).slice(1);if(n=n[o]=u.length?n[o]||{}:r,u.length){if(!h(n)||p(n))throw new Error("path node ['.".concat(o,"'] must be plain object {}!"));B(n,u,r)}},P=function(n,t,r){return B(n=n||{},t.split("."),r),n};export{o as VAL_TYPE,g as defaultValue,n as forEach,t as forEachReverse,I as get,u as getParamType,r as hasOwn,p as isArray,a as isBoolean,m as isEmpty,O as isEqual,v as isFunction,b as isNull,f as isNumber,d as isObject,h as isPlainObject,c as isString,l as isSymbol,i as isType,y as isUndefined,s as isUndefinedOrNull,j as noop,_ as obj,P as set,e as toString};
|
package/lib/type/index.d.ts
CHANGED
|
@@ -17,6 +17,21 @@ type TAny = any;
|
|
|
17
17
|
type TPlainObject = Record<string, TAny>;
|
|
18
18
|
type TPlainFunction = (...args: TAny[]) => TAny;
|
|
19
19
|
type TNoop = () => void;
|
|
20
|
+
type TUndefinedOrNull = undefined | null;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 全部属性变为必填,递归处理
|
|
24
|
+
*/
|
|
25
|
+
type RequireRecursive<T> = {
|
|
26
|
+
[P in keyof T]-?: T[P] extends object ? RequireRecursive<T[P]> : T[P];
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 全部属性变为可选,递归处理
|
|
31
|
+
*/
|
|
32
|
+
type PartialRecursive<T> = {
|
|
33
|
+
[P in keyof T]?: T[P] extends object ? PartialRecursive<T[P]> : T[P];
|
|
34
|
+
};
|
|
20
35
|
|
|
21
36
|
declare const VAL_TYPE: {
|
|
22
37
|
readonly boolean: "boolean";
|
|
@@ -179,7 +194,14 @@ declare const index_format: typeof format;
|
|
|
179
194
|
declare const index_omit: typeof omit;
|
|
180
195
|
declare const index_pick: typeof pick;
|
|
181
196
|
declare namespace index {
|
|
182
|
-
export {
|
|
197
|
+
export {
|
|
198
|
+
index_extend as extend,
|
|
199
|
+
index_filter as filter,
|
|
200
|
+
index_forEach as forEach,
|
|
201
|
+
index_format as format,
|
|
202
|
+
index_omit as omit,
|
|
203
|
+
index_pick as pick,
|
|
204
|
+
};
|
|
183
205
|
}
|
|
184
206
|
|
|
185
207
|
/**
|
|
@@ -190,4 +212,5 @@ declare namespace index {
|
|
|
190
212
|
*/
|
|
191
213
|
declare const set: (source: object | null | undefined, path: string, value: any) => object;
|
|
192
214
|
|
|
193
|
-
export {
|
|
215
|
+
export { VAL_TYPE, defaultValue, forEach$1 as forEach, forEachReverse, get, getParamType, hasOwn, isArray, isBoolean, isEmpty, isEqual, isFunction, isNull, isNumber, isObject, isPlainObject, isString, isSymbol, isType, isUndefined, isUndefinedOrNull, noop, index as obj, set, toString };
|
|
216
|
+
export type { PartialRecursive, RequireRecursive, TAny, TNoop, TPlainFunction, TPlainObject, TUndefinedOrNull, TVal };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cclr/lang",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.29",
|
|
4
4
|
"description": "js语言基础工具",
|
|
5
5
|
"author": "cclr <18843152354@163.com>",
|
|
6
6
|
"homepage": "",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"scripts": {
|
|
24
24
|
"test": "vitest",
|
|
25
25
|
"relese": "npm run test && npm publish",
|
|
26
|
-
"build": "
|
|
26
|
+
"build": "drr build",
|
|
27
27
|
"g:test": "vitest run",
|
|
28
|
-
"g:build": "
|
|
28
|
+
"g:build": "drr build"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "1d49762197a47eb6aa9b2bd012fead57e38c7ad1"
|
|
31
31
|
}
|