cafe-utility 26.9.0 → 26.10.0

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.
Files changed (3) hide show
  1. package/index.d.ts +2 -0
  2. package/index.js +27 -20
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -415,6 +415,7 @@ declare function removeEmptyValues(object: CafeObject): CafeObject;
415
415
  declare function filterObjectKeys<T>(object: CafeObject<T>, predicate: (key: string) => boolean): CafeObject<T>;
416
416
  declare function filterObjectValues<T>(object: CafeObject<T>, predicate: (value: T) => boolean): CafeObject<T>;
417
417
  declare function mapObject<T, K>(object: CafeObject<T>, mapper: (value: T) => K): CafeObject<K>;
418
+ declare function mapIterable<T, K>(iterable: Iterable<T>, mapper: (value: T, index: number) => K): K[];
418
419
  declare function rethrow<T>(asyncFn: () => Promise<T>, throwable: Error): Promise<T>;
419
420
  declare function setSomeOnObject(object: CafeObject, key: string, value: unknown): void;
420
421
  declare function setSomeDeep(target: CafeObject, targetPath: string, source: CafeObject, sourcePath: string): void;
@@ -805,6 +806,7 @@ export declare const Objects: {
805
806
  match: typeof match;
806
807
  sort: typeof sortObjectValues;
807
808
  map: typeof mapObject;
809
+ mapIterable: typeof mapIterable;
808
810
  filterKeys: typeof filterObjectKeys;
809
811
  filterValues: typeof filterObjectValues;
810
812
  rethrow: typeof rethrow;
package/index.js CHANGED
@@ -1789,6 +1789,12 @@ function mapObject(n, e) {
1789
1789
  for (const r of Object.entries(n)) t[r[0]] = e(r[1])
1790
1790
  return t
1791
1791
  }
1792
+ function mapIterable(n, e) {
1793
+ const t = []
1794
+ let r = 0
1795
+ for (const o of n) t.push(e(o, r++))
1796
+ return t
1797
+ }
1792
1798
  async function rethrow(n, e) {
1793
1799
  try {
1794
1800
  return await n()
@@ -2181,8 +2187,8 @@ function keccakPermutate(n) {
2181
2187
  a = n[9] ^ n[19] ^ n[29] ^ n[39] ^ n[49],
2182
2188
  h = (o << 1) | (i >>> 31),
2183
2189
  bn = (i << 1) | (o >>> 31),
2184
- d = l ^ h,
2185
- p = a ^ bn,
2190
+ p = l ^ h,
2191
+ d = a ^ bn,
2186
2192
  $n = (u << 1) | (f >>> 31),
2187
2193
  An = (f << 1) | (u >>> 31),
2188
2194
  m = t ^ $n,
@@ -2199,8 +2205,8 @@ function keccakPermutate(n) {
2199
2205
  Sn = (r << 1) | (t >>> 31),
2200
2206
  $ = c ^ kn,
2201
2207
  A = s ^ Sn
2202
- ;(n[0] ^= d),
2203
- (n[1] ^= p),
2208
+ ;(n[0] ^= p),
2209
+ (n[1] ^= d),
2204
2210
  (n[2] ^= m),
2205
2211
  (n[3] ^= g),
2206
2212
  (n[4] ^= w),
@@ -2209,8 +2215,8 @@ function keccakPermutate(n) {
2209
2215
  (n[7] ^= b),
2210
2216
  (n[8] ^= $),
2211
2217
  (n[9] ^= A),
2212
- (n[10] ^= d),
2213
- (n[11] ^= p),
2218
+ (n[10] ^= p),
2219
+ (n[11] ^= d),
2214
2220
  (n[12] ^= m),
2215
2221
  (n[13] ^= g),
2216
2222
  (n[14] ^= w),
@@ -2219,8 +2225,8 @@ function keccakPermutate(n) {
2219
2225
  (n[17] ^= b),
2220
2226
  (n[18] ^= $),
2221
2227
  (n[19] ^= A),
2222
- (n[20] ^= d),
2223
- (n[21] ^= p),
2228
+ (n[20] ^= p),
2229
+ (n[21] ^= d),
2224
2230
  (n[22] ^= m),
2225
2231
  (n[23] ^= g),
2226
2232
  (n[24] ^= w),
@@ -2229,8 +2235,8 @@ function keccakPermutate(n) {
2229
2235
  (n[27] ^= b),
2230
2236
  (n[28] ^= $),
2231
2237
  (n[29] ^= A),
2232
- (n[30] ^= d),
2233
- (n[31] ^= p),
2238
+ (n[30] ^= p),
2239
+ (n[31] ^= d),
2234
2240
  (n[32] ^= m),
2235
2241
  (n[33] ^= g),
2236
2242
  (n[34] ^= w),
@@ -2239,8 +2245,8 @@ function keccakPermutate(n) {
2239
2245
  (n[37] ^= b),
2240
2246
  (n[38] ^= $),
2241
2247
  (n[39] ^= A),
2242
- (n[40] ^= d),
2243
- (n[41] ^= p),
2248
+ (n[40] ^= p),
2249
+ (n[41] ^= d),
2244
2250
  (n[42] ^= m),
2245
2251
  (n[43] ^= g),
2246
2252
  (n[44] ^= w),
@@ -2292,8 +2298,8 @@ function keccakPermutate(n) {
2292
2298
  ln = (n[40] << 18) | (n[41] >>> 14),
2293
2299
  an = (n[41] << 18) | (n[40] >>> 14),
2294
2300
  hn = (n[42] << 2) | (n[43] >>> 30),
2295
- dn = (n[43] << 2) | (n[42] >>> 30),
2296
- pn = (n[45] << 29) | (n[44] >>> 3),
2301
+ pn = (n[43] << 2) | (n[42] >>> 30),
2302
+ dn = (n[45] << 29) | (n[44] >>> 3),
2297
2303
  mn = (n[44] << 29) | (n[45] >>> 3),
2298
2304
  gn = (n[47] << 24) | (n[46] >>> 8),
2299
2305
  wn = (n[46] << 24) | (n[47] >>> 8),
@@ -2313,11 +2319,11 @@ function keccakPermutate(n) {
2313
2319
  (n[11] = D ^ (~v & W)),
2314
2320
  (n[12] = q ^ (~H & en)),
2315
2321
  (n[13] = v ^ (~W & tn)),
2316
- (n[14] = H ^ (~en & pn)),
2322
+ (n[14] = H ^ (~en & dn)),
2317
2323
  (n[15] = W ^ (~tn & mn)),
2318
- (n[16] = en ^ (~pn & R)),
2324
+ (n[16] = en ^ (~dn & R)),
2319
2325
  (n[17] = tn ^ (~mn & D)),
2320
- (n[18] = pn ^ (~R & q)),
2326
+ (n[18] = dn ^ (~R & q)),
2321
2327
  (n[19] = mn ^ (~D & v)),
2322
2328
  (n[20] = O ^ (~U & Z)),
2323
2329
  (n[21] = T ^ (~j & Q)),
@@ -2344,11 +2350,11 @@ function keccakPermutate(n) {
2344
2350
  (n[42] = F ^ (~G & X)),
2345
2351
  (n[43] = z ^ (~Y & nn)),
2346
2352
  (n[44] = G ^ (~X & hn)),
2347
- (n[45] = Y ^ (~nn & dn)),
2353
+ (n[45] = Y ^ (~nn & pn)),
2348
2354
  (n[46] = X ^ (~hn & k)),
2349
- (n[47] = nn ^ (~dn & S)),
2355
+ (n[47] = nn ^ (~pn & S)),
2350
2356
  (n[48] = hn ^ (~k & F)),
2351
- (n[49] = dn ^ (~S & z)),
2357
+ (n[49] = pn ^ (~S & z)),
2352
2358
  (n[0] ^= IOTA_CONSTANTS[e * 2]),
2353
2359
  (n[1] ^= IOTA_CONSTANTS[e * 2 + 1])
2354
2360
  }
@@ -3094,6 +3100,7 @@ class AsyncQueue {
3094
3100
  match,
3095
3101
  sort: sortObjectValues,
3096
3102
  map: mapObject,
3103
+ mapIterable,
3097
3104
  filterKeys: filterObjectKeys,
3098
3105
  filterValues: filterObjectValues,
3099
3106
  rethrow,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cafe-utility",
3
- "version": "26.9.0",
3
+ "version": "26.10.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "exports": {