@welshman/lib 0.0.29 → 0.0.31
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/build/src/Tools.cjs +3 -3
- package/build/src/Tools.d.ts +1 -1
- package/build/src/Tools.mjs +1 -1
- package/package.json +1 -1
package/build/src/Tools.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.clamp = exports.toggle = exports.without = exports.remove = exports.difference = exports.intersection = exports.union = exports.append = exports.concat = exports.sleep = exports.displayDomain = exports.displayUrl = exports.stripProtocol = exports.randomId = exports.randomInt = exports.between = exports.mergeRight = exports.mergeLeft = exports.mapVals = exports.mapKeys = exports.range = exports.pick = exports.omitVals = exports.omit = exports.take = exports.drop = exports.avg = exports.sum = exports.min = exports.max = exports.gte = exports.gt = exports.lte = exports.lt = exports.dec = exports.inc = exports.div = exports.mul = exports.sub = exports.add = exports.num = exports.not = exports.always = exports.identity = exports.last = exports.ffirst = exports.first = exports.noop = exports.ifLet = exports.isNil = void 0;
|
|
4
|
-
exports.DAY = exports.HOUR = exports.MINUTE = exports.switcher = exports.pushToMapKey = exports.addToMapKey = exports.pushToKey = exports.addToKey = exports.batcher = exports.batch = exports.throttleWithValue = exports.throttle = exports.memoize = exports.once = exports.chunks = exports.chunk = exports.initArray = exports.indexBy = exports.groupBy = exports.sortBy = exports.sort = exports.uniqBy = exports.uniq = exports.partition = exports.flatten = exports.fromPairs = exports.ensureNumber = exports.ensurePlural = exports.toIterable = exports.isIterable = exports.
|
|
4
|
+
exports.DAY = exports.HOUR = exports.MINUTE = exports.switcher = exports.pushToMapKey = exports.addToMapKey = exports.pushToKey = exports.addToKey = exports.batcher = exports.batch = exports.throttleWithValue = exports.throttle = exports.memoize = exports.once = exports.chunks = exports.chunk = exports.initArray = exports.indexBy = exports.groupBy = exports.sortBy = exports.sort = exports.uniqBy = exports.uniq = exports.partition = exports.flatten = exports.fromPairs = exports.ensureNumber = exports.ensurePlural = exports.toIterable = exports.isIterable = exports.sample = exports.shuffle = exports.choice = exports.insert = exports.splitAt = exports.hash = exports.assoc = exports.prop = exports.ne = exports.eq = exports.nthNe = exports.nthEq = exports.nth = exports.equals = exports.isPojo = exports.ellipsize = exports.tryCatch = exports.setJson = exports.getJson = exports.parseJson = void 0;
|
|
5
5
|
exports.bech32ToHex = exports.hexToBech32 = exports.uploadFile = exports.postJson = exports.fetchJson = exports.ms = exports.ago = exports.now = exports.int = exports.YEAR = exports.QUARTER = exports.MONTH = exports.WEEK = void 0;
|
|
6
6
|
const base_1 = require("@scure/base");
|
|
7
7
|
const isNil = (x) => [null, undefined].includes(x);
|
|
@@ -264,8 +264,8 @@ const choice = (xs) => xs[Math.floor(xs.length * Math.random())];
|
|
|
264
264
|
exports.choice = choice;
|
|
265
265
|
const shuffle = (xs) => Array.from(xs).sort(() => Math.random() > 0.5 ? 1 : -1);
|
|
266
266
|
exports.shuffle = shuffle;
|
|
267
|
-
const
|
|
268
|
-
exports.
|
|
267
|
+
const sample = (n, xs) => (0, exports.shuffle)(xs).slice(0, n);
|
|
268
|
+
exports.sample = sample;
|
|
269
269
|
const isIterable = (x) => Symbol.iterator in Object(x);
|
|
270
270
|
exports.isIterable = isIterable;
|
|
271
271
|
const toIterable = (x) => (0, exports.isIterable)(x) ? x : [x];
|
package/build/src/Tools.d.ts
CHANGED
|
@@ -69,7 +69,7 @@ export declare const splitAt: <T>(n: number, xs: T[]) => T[][];
|
|
|
69
69
|
export declare const insert: <T>(n: number, x: T, xs: T[]) => T[];
|
|
70
70
|
export declare const choice: <T>(xs: T[]) => T;
|
|
71
71
|
export declare const shuffle: <T>(xs: Iterable<T>) => T[];
|
|
72
|
-
export declare const
|
|
72
|
+
export declare const sample: <T>(n: number, xs: T[]) => T[];
|
|
73
73
|
export declare const isIterable: (x: any) => boolean;
|
|
74
74
|
export declare const toIterable: (x: any) => any;
|
|
75
75
|
export declare const ensurePlural: <T>(x: T | T[]) => T[];
|
package/build/src/Tools.mjs
CHANGED
|
@@ -190,7 +190,7 @@ export const splitAt = (n, xs) => [xs.slice(0, n), xs.slice(n)];
|
|
|
190
190
|
export const insert = (n, x, xs) => [...xs.slice(0, n), x, ...xs.slice(n)];
|
|
191
191
|
export const choice = (xs) => xs[Math.floor(xs.length * Math.random())];
|
|
192
192
|
export const shuffle = (xs) => Array.from(xs).sort(() => Math.random() > 0.5 ? 1 : -1);
|
|
193
|
-
export const
|
|
193
|
+
export const sample = (n, xs) => shuffle(xs).slice(0, n);
|
|
194
194
|
export const isIterable = (x) => Symbol.iterator in Object(x);
|
|
195
195
|
export const toIterable = (x) => isIterable(x) ? x : [x];
|
|
196
196
|
export const ensurePlural = (x) => (x instanceof Array ? x : [x]);
|