Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
bluelovers committed Jun 1, 2022
1 parent 69e8484 commit 52d4958
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 140 deletions.
2 changes: 1 addition & 1 deletion packages/array-group-to-record/dist/index.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

'use strict'

if (process.env.NODE_ENV === 'production') {
if (typeof process !== 'undefined' && process.env.NODE_ENV === 'production') {
module.exports = require('./index.cjs.production.min.cjs')
} else {
module.exports = require('./index.cjs.development.cjs')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("hash-sum"));function r(e){var r;const n=null!==(r=null==e?void 0:e.getKey)&&void 0!==r?r:e=>t.default(e);return{...e,getKey:n}}function n(e,t){var n;const{getKey:o,init:u}=r(t);return e.reduce(((e,t,r,n)=>{var u;const l=o(t,r,n);return null!==(u=e[l])&&void 0!==u||(e[l]=[]),e[l].push(t),e}),null!==(n=null==u?void 0:u())&&void 0!==n?n:{})}exports.arrayGroupToMap=function(e,t){var n;const{getKey:o,init:u}=r(t);return e.reduce(((e,t,r,n)=>{var u;const l=o(t,r,n),i=null!==(u=e.get(l))&&void 0!==u?u:[];return i.push(t),e.set(l,i),e}),null!==(n=null==u?void 0:u())&&void 0!==n?n:new Map)},exports.arrayGroupToRecord=n,exports.default=n,exports.handleOptions=r,exports.sumGroup=function(e){let t=0;return void 0===e.forEach&&(e=Object.values(e)),e.forEach((e=>t+=e.length)),t};
"use strict";function _interopDefaultLegacy(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}Object.defineProperty(exports,"__esModule",{value:!0});var e=_interopDefaultLegacy(require("hash-sum"));function handleOptions(r){var o;const t=null!==(o=null==r?void 0:r.getKey)&&void 0!==o?o:r=>e.default(r);return{...r,getKey:t}}function arrayGroupToRecord(e,r){var o;const{getKey:t,init:n}=handleOptions(r);return e.reduce(((e,r,o,n)=>{var u;const a=t(r,o,n);return null!==(u=e[a])&&void 0!==u||(e[a]=[]),e[a].push(r),e}),null!==(o=null==n?void 0:n())&&void 0!==o?o:{})}exports.arrayGroupToMap=function arrayGroupToMap(e,r){var o;const{getKey:t,init:n}=handleOptions(r);return e.reduce(((e,r,o,n)=>{var u;const a=t(r,o,n),l=null!==(u=e.get(a))&&void 0!==u?u:[];return l.push(r),e.set(a,l),e}),null!==(o=null==n?void 0:n())&&void 0!==o?o:new Map)},exports.arrayGroupToRecord=arrayGroupToRecord,exports.default=arrayGroupToRecord,exports.handleOptions=handleOptions,exports.sumGroup=function sumGroup(e){let r=0;return void 0===e.forEach&&(e=Object.values(e)),e.forEach((e=>r+=e.length)),r};
//# sourceMappingURL=index.cjs.production.min.cjs.map
73 changes: 28 additions & 45 deletions packages/array-group-to-record/dist/index.esm.mjs
Original file line number Diff line number Diff line change
@@ -1,55 +1,38 @@
import hashSum from 'hash-sum';

function handleOptions(options) {
var _options$getKey;

const getKey = (_options$getKey = options === null || options === void 0 ? void 0 : options.getKey) !== null && _options$getKey !== void 0 ? _options$getKey : item => hashSum(item);
return { ...options,
getKey
import r from "hash-sum";

function handleOptions(o) {
var n;
const e = null !== (n = null == o ? void 0 : o.getKey) && void 0 !== n ? n : o => r(o);
return {
...o,
getKey: e
};
}
function arrayGroupToRecord(arr, options) {
var _init;

const {
getKey,
init
} = handleOptions(options);
return arr.reduce((map, item, index, arr) => {
var _map$id;

const id = getKey(item, index, arr);
(_map$id = map[id]) !== null && _map$id !== void 0 ? _map$id : map[id] = [];
map[id].push(item);
return map;
}, (_init = init === null || init === void 0 ? void 0 : init()) !== null && _init !== void 0 ? _init : {});
function arrayGroupToRecord(r, o) {
var n;
const {getKey: e, init: u} = handleOptions(o);
return r.reduce(((r, o, n, u) => {
var t;
const a = e(o, n, u);
return null !== (t = r[a]) && void 0 !== t || (r[a] = []), r[a].push(o), r;
}), null !== (n = null == u ? void 0 : u()) && void 0 !== n ? n : {});
}
function arrayGroupToMap(arr, options) {
var _init2;

const {
getKey,
init
} = handleOptions(options);
return arr.reduce((map, item, index, arr) => {
var _map$get;

const id = getKey(item, index, arr);
const a = (_map$get = map.get(id)) !== null && _map$get !== void 0 ? _map$get : [];
a.push(item);
map.set(id, a);
return map;
}, (_init2 = init === null || init === void 0 ? void 0 : init()) !== null && _init2 !== void 0 ? _init2 : new Map());
function arrayGroupToMap(r, o) {
var n;
const {getKey: e, init: u} = handleOptions(o);
return r.reduce(((r, o, n, u) => {
var t;
const a = e(o, n, u), l = null !== (t = r.get(a)) && void 0 !== t ? t : [];
return l.push(o), r.set(a, l), r;
}), null !== (n = null == u ? void 0 : u()) && void 0 !== n ? n : new Map);
}
function sumGroup(group) {
let len = 0;

if (typeof group.forEach === 'undefined') {
group = Object.values(group);
}

group.forEach(b => len += b.length);
return len;
function sumGroup(r) {
let o = 0;
return void 0 === r.forEach && (r = Object.values(r)), r.forEach((r => o += r.length)),
o;
}

export { arrayGroupToMap, arrayGroupToRecord, arrayGroupToRecord as default, handleOptions, sumGroup };
Expand Down
2 changes: 1 addition & 1 deletion packages/distribute-group-to-array/dist/index.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

'use strict'

if (process.env.NODE_ENV === 'production') {
if (typeof process !== 'undefined' && process.env.NODE_ENV === 'production') {
module.exports = require('./index.cjs.production.min.cjs')
} else {
module.exports = require('./index.cjs.development.cjs')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"use strict";function e(e){const r=[];for(let o=0;o<e;o++)r.push([]);return r}function r(r,t){var n,l,u;void 0!==r.entries&&(r=o(r));const i=null!==(n=null==t||null===(l=t.init)||void 0===l?void 0:l.call(t))&&void 0!==n?n:e(null!==(u=null==t?void 0:t.groupArraySize)&&void 0!==u?u:4),s=i.length,{names:d,record:c}=Object.entries(r).reduce(((e,[r,o])=>(e.names.push(r),e.record[r]=o.slice(),e)),{names:[],record:{}});let p=s-1;do{let e;for(let r of d){var a;e=null===(a=c[r])||void 0===a?void 0:a.pop(),e?i[p%s].push(e):delete c[r]}e&&p++}while(Object.keys(c).length);return i}function o(e){const r={};for(let[o,t]of e.entries())r[o]=t;return r}function t(e,o){return r(e,o).flat()}Object.defineProperty(exports,"__esModule",{value:!0}),exports._createGroupArray=e,exports.default=t,exports.distributeGroupToArray=t,exports.distributeGroupToArrayCore=r,exports.mapToRecord=o;
"use strict";function _createGroupArray(r){const e=[];for(let o=0;o<r;o++)e.push([]);return e}function distributeGroupToArrayCore(r,e){var o,t,u;void 0!==r.entries&&(r=mapToRecord(r));const i=null!==(o=null==e||null===(t=e.init)||void 0===t?void 0:t.call(e))&&void 0!==o?o:_createGroupArray(null!==(u=null==e?void 0:e.groupArraySize)&&void 0!==u?u:4),n=i.length,{names:s,record:a}=Object.entries(r).reduce(((r,[e,o])=>(r.names.push(e),r.record[e]=o.slice(),r)),{names:[],record:{}});let d=n-1;do{let r;for(let e of s){var p;r=null===(p=a[e])||void 0===p?void 0:p.pop(),r?i[d%n].push(r):delete a[e]}r&&d++}while(Object.keys(a).length);return i}function mapToRecord(r){const e={};for(let[o,t]of r.entries())e[o]=t;return e}function distributeGroupToArray(r,e){return distributeGroupToArrayCore(r,e).flat()}Object.defineProperty(exports,"__esModule",{value:!0}),exports._createGroupArray=_createGroupArray,exports.default=distributeGroupToArray,exports.distributeGroupToArray=distributeGroupToArray,exports.distributeGroupToArrayCore=distributeGroupToArrayCore,exports.mapToRecord=mapToRecord;
//# sourceMappingURL=index.cjs.production.min.cjs.map
78 changes: 24 additions & 54 deletions packages/distribute-group-to-array/dist/index.esm.mjs
Original file line number Diff line number Diff line change
@@ -1,67 +1,37 @@
function _createGroupArray(length) {
const arr = [];

for (let i = 0; i < length; i++) {
arr.push([]);
}

return arr;
function _createGroupArray(r) {
const e = [];
for (let o = 0; o < r; o++) e.push([]);
return e;
}
function distributeGroupToArrayCore(group, options) {
var _options$init, _options$init2, _options$groupArraySi;

if (typeof group.entries !== 'undefined') {
group = mapToRecord(group);
}

const arr = (_options$init = options === null || options === void 0 ? void 0 : (_options$init2 = options.init) === null || _options$init2 === void 0 ? void 0 : _options$init2.call(options)) !== null && _options$init !== void 0 ? _options$init : _createGroupArray((_options$groupArraySi = options === null || options === void 0 ? void 0 : options.groupArraySize) !== null && _options$groupArraySi !== void 0 ? _options$groupArraySi : 4);
const len = arr.length;
const {
names,
record
} = Object.entries(group).reduce((a, [k, v]) => {
a.names.push(k);
a.record[k] = v.slice();
return a;
}, {
function distributeGroupToArrayCore(r, e) {
var o, t, u;
void 0 !== r.entries && (r = mapToRecord(r));
const i = null !== (o = null == e || null === (t = e.init) || void 0 === t ? void 0 : t.call(e)) && void 0 !== o ? o : _createGroupArray(null !== (u = null == e ? void 0 : e.groupArraySize) && void 0 !== u ? u : 4), n = i.length, {names: l, record: a} = Object.entries(r).reduce(((r, [e, o]) => (r.names.push(e),
r.record[e] = o.slice(), r)), {
names: [],
record: {}
});
let i = len - 1;

let d = n - 1;
do {
let item;

for (let name of names) {
var _record$name;

item = (_record$name = record[name]) === null || _record$name === void 0 ? void 0 : _record$name.pop();

if (item) {
arr[i % len].push(item);
} else {
delete record[name];
}
}

if (item) {
i++;
let r;
for (let e of l) {
var c;
r = null === (c = a[e]) || void 0 === c ? void 0 : c.pop(), r ? i[d % n].push(r) : delete a[e];
}
} while (Object.keys(record).length);

return arr;
r && d++;
} while (Object.keys(a).length);
return i;
}
function mapToRecord(map) {
const record = {};

for (let [k, v] of map.entries()) {
record[k] = v;
}

return record;
function mapToRecord(r) {
const e = {};
for (let [o, t] of r.entries()) e[o] = t;
return e;
}
function distributeGroupToArray(group, options) {
return distributeGroupToArrayCore(group, options).flat();

function distributeGroupToArray(r, e) {
return distributeGroupToArrayCore(r, e).flat();
}

export { _createGroupArray, distributeGroupToArray as default, distributeGroupToArray, distributeGroupToArrayCore, mapToRecord };
Expand Down
2 changes: 1 addition & 1 deletion packages/string-natural-compare/dist/index.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

'use strict'

if (process.env.NODE_ENV === 'production') {
if (typeof process !== 'undefined' && process.env.NODE_ENV === 'production') {
module.exports = require('./index.cjs.production.min.cjs')
} else {
module.exports = require('./index.cjs.development.cjs')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("string-natural-compare"));function r(e,r,n){let s;if("number"==typeof e&&"number"==typeof r)s=e-r;else{if("number"==typeof e?e=String(e):"number"==typeof r&&(r=String(r)),e===r)return 0;s=t.default(e,r,n)}return 0!==s&&null!=n&&n.desc&&(s=0-s),s}function n(e){return(t,n)=>r(t,n,e)}const s=n({caseInsensitive:!0});r.createNew=n,r.compareCaseInsensitive=s,r.caseInsensitive=s,r.default=r,Object.defineProperty(r,"__esModule",{value:!0}),exports.caseInsensitive=s,exports.compareCaseInsensitive=s,exports.createNew=n,exports.default=r,exports.naturalCompare=r;
"use strict";function _interopDefaultLegacy(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}Object.defineProperty(exports,"__esModule",{value:!0});var e=_interopDefaultLegacy(require("string-natural-compare"));function naturalCompare(r,t,a){let n;if("number"==typeof r&&"number"==typeof t)n=r-t;else{if("number"==typeof r?r=String(r):"number"==typeof t&&(t=String(t)),r===t)return 0;n=e.default(r,t,a)}return 0!==n&&null!=a&&a.desc&&(n=0-n),n}function createNew(e){return(r,t)=>naturalCompare(r,t,e)}const r=createNew({caseInsensitive:!0});naturalCompare.createNew=createNew,naturalCompare.compareCaseInsensitive=r,naturalCompare.caseInsensitive=r,naturalCompare.default=naturalCompare,Object.defineProperty(naturalCompare,"__esModule",{value:!0}),exports.caseInsensitive=r,exports.compareCaseInsensitive=r,exports.createNew=createNew,exports.default=naturalCompare,exports.naturalCompare=naturalCompare;
//# sourceMappingURL=index.cjs.production.min.cjs.map
54 changes: 19 additions & 35 deletions packages/string-natural-compare/dist/index.esm.mjs
Original file line number Diff line number Diff line change
@@ -1,43 +1,27 @@
import _naturalCompare from 'string-natural-compare';
import e from "string-natural-compare";

function naturalCompare(a, b, opts) {
let i;

if (typeof a === 'number' && typeof b === 'number') {
i = a - b;
} else {
if (typeof a === 'number') {
a = String(a);
} else if (typeof b === 'number') {
b = String(b);
}

if (a === b) {
return 0;
}

i = _naturalCompare(a, b, opts);
}

if (i !== 0 && opts !== null && opts !== void 0 && opts.desc) {
i = 0 - i;
function naturalCompare(a, r, t) {
let n;
if ("number" == typeof a && "number" == typeof r) n = a - r; else {
if ("number" == typeof a ? a = String(a) : "number" == typeof r && (r = String(r)),
a === r) return 0;
n = e(a, r, t);
}

return i;
return 0 !== n && null != t && t.desc && (n = 0 - n), n;
}
function createNew(opts) {
return (a, b) => naturalCompare(a, b, opts);

function createNew(e) {
return (a, r) => naturalCompare(a, r, e);
}
const compareCaseInsensitive = /*#__PURE__*/createNew({
caseInsensitive: true

const a = createNew({
caseInsensitive: !0
});
naturalCompare.createNew = createNew;
naturalCompare.compareCaseInsensitive = compareCaseInsensitive;
naturalCompare.caseInsensitive = compareCaseInsensitive;
naturalCompare.default = naturalCompare;
Object.defineProperty(naturalCompare, "__esModule", {
value: true

naturalCompare.createNew = createNew, naturalCompare.compareCaseInsensitive = a,
naturalCompare.caseInsensitive = a, naturalCompare.default = naturalCompare, Object.defineProperty(naturalCompare, "__esModule", {
value: !0
});

export { compareCaseInsensitive as caseInsensitive, compareCaseInsensitive, createNew, naturalCompare as default, naturalCompare };
export { a as caseInsensitive, a as compareCaseInsensitive, createNew, naturalCompare as default, naturalCompare };
//# sourceMappingURL=index.esm.mjs.map

0 comments on commit 52d4958

Please sign in to comment.