@acrool/js-utils
Advanced tools
+10
-1
@@ -133,4 +133,13 @@ import { SortOrder, TArrayOrEmpty, TGroupByFn, TGroupTreeBy, TSortByFn } from './types'; | ||
| */ | ||
| export declare function arraySplit<T, A extends TArrayOrEmpty<T>>(arrayData: A, splitCount: number): A[] | undefined; | ||
| /** | ||
| * 分割陣列 | ||
| * | ||
| * arraySplit([1,2,3,4,5], 2) | ||
| * > [[1,2], [3,4], [5]] | ||
| * | ||
| * @param arrayData | ||
| * @param splitCount | ||
| */ | ||
| export declare function arraySplit<T>(arrayData: TArrayOrEmpty<T>, splitCount: number): T[][] | undefined; | ||
| /** | ||
| * GroupBy | ||
@@ -137,0 +146,0 @@ * |
@@ -1,1 +0,1 @@ | ||
| "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function s(n,e){return n?[e].concat(n.slice(0)):[e]}function g(n,e){return n?n.slice(0).concat(e):[e]}function l(n,e,r){return n?[...n.slice(0,e),r,...n.slice(e)]:[r]}function p(n,e,r){if(!n||e===r)return n;const t=[...n],u=t[e];return t.splice(e,1),t.splice(r,0,u),t}function d(n,e){if(!n)return n;const r=n.findIndex(e);return r===-1?n:i(n,r)}function h(n,e){if(!n)return n;const r=n.findIndex(e.finder);return r===-1?n:c(n,r,e.updater)}function i(n,e){return!n||e===-1||e>n.length-1?n:[...n.slice(0,e),...n.slice(e+1)]}function c(n,e,r){if(e===-1||!n||e>n.length-1)return n;const t={...n[e]};r(t);const u=[...n];return u[e]=t,u}function m(n,e){if(!n)return n;const r=new Set,t=new Array;for(const u of n){const o=e?e(u):u;r.has(o)||(r.add(o),t.push(u))}return t}function A(n,e){return n?n.join(e):""}function B(n){return n==null?void 0:n[0]}function S(n,e){if(!n)return;const r=Math.ceil(n.length/e);return new Array(r).fill([]).map((u,o)=>n.slice(o*e,o*e+e))}function I(n,e){return n.reduce((r,t)=>{const u=e(t);return r[u]||(r[u]=[]),r[u].push(t),r},{})}function v(n,e){const r={};return n.forEach(t=>{const{groupKey:u,groupData:o,child:f}=e(t);r[u]||(r[u]={...o,children:[]}),r[u].children.push(f)}),Object.keys(r).map(t=>r[t])}function w(n,e){const r=[...n];return r.sort(e),r}function F(n,e="ASC"){return function(r,t){const u=n(r),o=n(t);return u<o?e==="ASC"?-1:1:u>o?e==="ASC"?1:-1:0}}const T=(n,e="skeleton_")=>Array.from({length:n}).map((r,t)=>`${e}${t}`);function b(n){return e=>{const t=(n.indexOf(e)+1)%n.length;return n[t]}}exports.arrayFirst=B;exports.arrayJoin=A;exports.arraySplit=S;exports.generateSortByProperty=F;exports.generatorArray=T;exports.generatorArrayToggle=b;exports.groupBy=I;exports.groupTreeBy=v;exports.insert=l;exports.move=p;exports.pull=s;exports.push=g;exports.removeByIndex=i;exports.removeFind=d;exports.sort=w;exports.unique=m;exports.updateByIndex=c;exports.updateFind=h; | ||
| "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function s(n,e){const r=e&&typeof e=="object"?{...e}:e;return n?[r].concat(n.slice(0)):[r]}function g(n,e){const r=e&&typeof e=="object"?{...e}:e;return n?n.slice(0).concat(r):[r]}function p(n,e,r){const t=r&&typeof r=="object"?{...r}:r;return n?[...n.slice(0,e),t,...n.slice(e)]:[t]}function l(n,e,r){if(!n||e===r)return n;const t=[...n],o=t[e];return t.splice(e,1),t.splice(r,0,o),t}function d(n,e){if(!n)return n;const r=n.findIndex(e);return r===-1?n:c(n,r)}function m(n,e){if(!n)return n;const r=n.findIndex(e.finder);return r===-1?n:i(n,r,e.updater)}function c(n,e){return!n||e===-1||e>n.length-1?n:[...n.slice(0,e),...n.slice(e+1)]}function i(n,e,r){if(e===-1||!n||e>n.length-1)return n;const t={...n[e]};r(t);const o=[...n];return o[e]=t,o}function h(n,e){if(!n)return n;const r=new Set,t=new Array;for(const o of n){const u=e?e(o):o;r.has(u)||(r.add(u),t.push(o))}return t}function A(n,e){return n?n.join(e):""}function B(n){return n==null?void 0:n[0]}function S(n,e){if(!n||e<=0)return;const r=Math.ceil(n.length/e);return Array.from({length:r},(t,o)=>n.slice(o*e,(o+1)*e))}function I(n,e){return n.reduce((r,t)=>{const o=e(t);return r[o]||(r[o]=[]),r[o].push(t),r},{})}function v(n,e){const r={};return n.forEach(t=>{const{groupKey:o,groupData:u,child:f}=e(t);r[o]||(r[o]={...u,children:[]}),r[o].children.push(f)}),Object.keys(r).map(t=>r[t])}function b(n,e){const r=[...n];return r.sort(e),r}function j(n,e="ASC"){return function(r,t){const o=n(r),u=n(t);return o<u?e==="ASC"?-1:1:o>u?e==="ASC"?1:-1:0}}const w=(n,e="skeleton_")=>Array.from({length:n}).map((r,t)=>`${e}${t}`);function F(n){return e=>{const t=(n.indexOf(e)+1)%n.length;return n[t]}}exports.arrayFirst=B;exports.arrayJoin=A;exports.arraySplit=S;exports.generateSortByProperty=j;exports.generatorArray=w;exports.generatorArrayToggle=F;exports.groupBy=I;exports.groupTreeBy=v;exports.insert=p;exports.move=l;exports.pull=s;exports.push=g;exports.removeByIndex=c;exports.removeFind=d;exports.sort=b;exports.unique=h;exports.updateByIndex=i;exports.updateFind=m; |
+59
-56
| function s(n, e) { | ||
| return n ? [e].concat(n.slice(0)) : [e]; | ||
| const t = e && typeof e == "object" ? { ...e } : e; | ||
| return n ? [t].concat(n.slice(0)) : [t]; | ||
| } | ||
| function l(n, e) { | ||
| return n ? n.slice(0).concat(e) : [e]; | ||
| function g(n, e) { | ||
| const t = e && typeof e == "object" ? { ...e } : e; | ||
| return n ? n.slice(0).concat(t) : [t]; | ||
| } | ||
| function g(n, e, t) { | ||
| return n ? [...n.slice(0, e), t, ...n.slice(e)] : [t]; | ||
| function p(n, e, t) { | ||
| const o = t && typeof t == "object" ? { ...t } : t; | ||
| return n ? [...n.slice(0, e), o, ...n.slice(e)] : [o]; | ||
| } | ||
| function p(n, e, t) { | ||
| function l(n, e, t) { | ||
| if (!n || e === t) | ||
| return n; | ||
| const u = [...n], r = u[e]; | ||
| return u.splice(e, 1), u.splice(t, 0, r), u; | ||
| const o = [...n], u = o[e]; | ||
| return o.splice(e, 1), o.splice(t, 0, u), o; | ||
| } | ||
@@ -21,3 +24,3 @@ function h(n, e) { | ||
| } | ||
| function A(n, e) { | ||
| function m(n, e) { | ||
| if (!n) return n; | ||
@@ -32,79 +35,79 @@ const t = n.findIndex(e.finder); | ||
| if (e === -1 || !n || e > n.length - 1) return n; | ||
| const u = { ...n[e] }; | ||
| t(u); | ||
| const r = [...n]; | ||
| return r[e] = u, r; | ||
| const o = { ...n[e] }; | ||
| t(o); | ||
| const u = [...n]; | ||
| return u[e] = o, u; | ||
| } | ||
| function d(n, e) { | ||
| function A(n, e) { | ||
| if (!n) return n; | ||
| const t = /* @__PURE__ */ new Set(), u = new Array(); | ||
| for (const r of n) { | ||
| const o = e ? e(r) : r; | ||
| t.has(o) || (t.add(o), u.push(r)); | ||
| const t = /* @__PURE__ */ new Set(), o = new Array(); | ||
| for (const u of n) { | ||
| const r = e ? e(u) : u; | ||
| t.has(r) || (t.add(r), o.push(u)); | ||
| } | ||
| return u; | ||
| return o; | ||
| } | ||
| function m(n, e) { | ||
| function d(n, e) { | ||
| return n ? n.join(e) : ""; | ||
| } | ||
| function w(n) { | ||
| function I(n) { | ||
| return n == null ? void 0 : n[0]; | ||
| } | ||
| function I(n, e) { | ||
| if (!n) return; | ||
| function w(n, e) { | ||
| if (!n || e <= 0) return; | ||
| const t = Math.ceil(n.length / e); | ||
| return new Array(t).fill([]).map((r, o) => n.slice(o * e, o * e + e)); | ||
| return Array.from({ length: t }, (o, u) => n.slice(u * e, (u + 1) * e)); | ||
| } | ||
| function S(n, e) { | ||
| return n.reduce((t, u) => { | ||
| const r = e(u); | ||
| return t[r] || (t[r] = []), t[r].push(u), t; | ||
| return n.reduce((t, o) => { | ||
| const u = e(o); | ||
| return t[u] || (t[u] = []), t[u].push(o), t; | ||
| }, {}); | ||
| } | ||
| function B(n, e) { | ||
| function b(n, e) { | ||
| const t = {}; | ||
| return n.forEach((u) => { | ||
| const { groupKey: r, groupData: o, child: c } = e(u); | ||
| t[r] || (t[r] = { | ||
| ...o, | ||
| return n.forEach((o) => { | ||
| const { groupKey: u, groupData: r, child: c } = e(o); | ||
| t[u] || (t[u] = { | ||
| ...r, | ||
| children: [] | ||
| }), t[r].children.push(c); | ||
| }), Object.keys(t).map((u) => t[u]); | ||
| }), t[u].children.push(c); | ||
| }), Object.keys(t).map((o) => t[o]); | ||
| } | ||
| function k(n, e) { | ||
| function j(n, e) { | ||
| const t = [...n]; | ||
| return t.sort(e), t; | ||
| } | ||
| function v(n, e = "ASC") { | ||
| return function(t, u) { | ||
| const r = n(t), o = n(u); | ||
| return r < o ? e === "ASC" ? -1 : 1 : r > o ? e === "ASC" ? 1 : -1 : 0; | ||
| function B(n, e = "ASC") { | ||
| return function(t, o) { | ||
| const u = n(t), r = n(o); | ||
| return u < r ? e === "ASC" ? -1 : 1 : u > r ? e === "ASC" ? 1 : -1 : 0; | ||
| }; | ||
| } | ||
| const F = (n, e = "skeleton_") => Array.from({ length: n }).map((t, u) => `${e}${u}`); | ||
| function b(n) { | ||
| const k = (n, e = "skeleton_") => Array.from({ length: n }).map((t, o) => `${e}${o}`); | ||
| function v(n) { | ||
| return (e) => { | ||
| const u = (n.indexOf(e) + 1) % n.length; | ||
| return n[u]; | ||
| const o = (n.indexOf(e) + 1) % n.length; | ||
| return n[o]; | ||
| }; | ||
| } | ||
| export { | ||
| w as arrayFirst, | ||
| m as arrayJoin, | ||
| I as arraySplit, | ||
| v as generateSortByProperty, | ||
| F as generatorArray, | ||
| b as generatorArrayToggle, | ||
| I as arrayFirst, | ||
| d as arrayJoin, | ||
| w as arraySplit, | ||
| B as generateSortByProperty, | ||
| k as generatorArray, | ||
| v as generatorArrayToggle, | ||
| S as groupBy, | ||
| B as groupTreeBy, | ||
| g as insert, | ||
| p as move, | ||
| b as groupTreeBy, | ||
| p as insert, | ||
| l as move, | ||
| s as pull, | ||
| l as push, | ||
| g as push, | ||
| i as removeByIndex, | ||
| h as removeFind, | ||
| k as sort, | ||
| d as unique, | ||
| j as sort, | ||
| A as unique, | ||
| f as updateByIndex, | ||
| A as updateFind | ||
| m as updateFind | ||
| }; |
+1
-1
| { | ||
| "name": "@acrool/js-utils", | ||
| "version": "3.2.22", | ||
| "version": "3.2.23-alpha.0", | ||
| "description": "Common javascript utils methods for project development", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
104565
0.4%2299
0.52%14
7.69%