@blake.regalia/belt
Advanced tools
Comparing version 0.12.0 to 0.13.0
@@ -69,11 +69,11 @@ import type { Dict, JsonObject } from './types'; | ||
/** | ||
* Helper type for defining the expected type for `[].reduce` alias | ||
* Map object entries | ||
*/ | ||
type ReduceParameters<w_value extends any = any> = Parameters<Array<w_value>['reduce']>; | ||
export declare const odem: <w_out extends unknown, si_key extends string, w_value extends unknown>(h_object: Record<si_key, w_value>, f_map: (g_entry: [si_key, w_value], i_index: number, a_all: [si_key, w_value][]) => w_out) => w_out[]; | ||
/** | ||
* Reduce object entries to an arbitrary type | ||
*/ | ||
export declare const oder: <w_out extends unknown, si_key extends string, w_value extends unknown>(h_thing: Record<si_key, w_value>, f_reduce: ReduceParameters[0], w_init: w_out) => w_out; | ||
export declare const oder: <w_out extends unknown, si_key extends string, w_value extends unknown>(h_thing: Record<si_key, w_value>, f_reduce: (w_prev: w_out, g_entry: [si_key, w_value], i_index: number, a_all: [si_key, w_value][]) => w_out, w_init: w_out) => w_out; | ||
/** | ||
* Reduce object entries to an array via concatenation | ||
* Reduce object entries to an array via concatenation (with filtering) | ||
*/ | ||
@@ -80,0 +80,0 @@ export declare const oderac: <w_out extends unknown, si_key extends string, w_value extends unknown>(h_thing: Record<si_key, w_value>, f_concat: (si_key: si_key, w_value: w_value, i_entry: number) => w_out, b_add_undefs?: boolean) => w_out[]; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.remove = exports.shuffle = exports.crypto_random_int = exports.random_int = exports.crypto_random = exports.defer_many = exports.defer = exports.microtask = exports.forever = exports.with_timeout = exports.timeout_exec = exports.timeout = exports.fodemtv = exports.oderom = exports.oderaf = exports.oderac = exports.oder = exports.ofe = exports.ode = exports.odv = exports.oda = exports.oc = exports.escape_regex = exports.deduplicate = exports.interjoin = exports.fold = exports.is_dict_es = exports.is_dict = exports.proper = exports.F_IDENTITY = exports.F_NOOP = exports.__UNDEFINED = exports.ATU8_NIL = void 0; | ||
exports.remove = exports.shuffle = exports.crypto_random_int = exports.random_int = exports.crypto_random = exports.defer_many = exports.defer = exports.microtask = exports.forever = exports.with_timeout = exports.timeout_exec = exports.timeout = exports.fodemtv = exports.oderom = exports.oderaf = exports.oderac = exports.oder = exports.odem = exports.ofe = exports.ode = exports.odv = exports.oda = exports.oc = exports.escape_regex = exports.deduplicate = exports.interjoin = exports.fold = exports.is_dict_es = exports.is_dict = exports.proper = exports.F_IDENTITY = exports.F_NOOP = exports.__UNDEFINED = exports.ATU8_NIL = void 0; | ||
/** | ||
@@ -135,2 +135,7 @@ * Utility nil buffer constant | ||
/** | ||
* Map object entries | ||
*/ | ||
const odem = (h_object, f_map) => (0, exports.ode)(h_object).map(f_map); | ||
exports.odem = odem; | ||
/** | ||
* Reduce object entries to an arbitrary type | ||
@@ -141,9 +146,10 @@ */ | ||
/** | ||
* Reduce object entries to an array via concatenation | ||
* Reduce object entries to an array via concatenation (with filtering) | ||
*/ | ||
const oderac = (h_thing, f_concat, b_add_undefs = false) => (0, exports.ode)(h_thing).reduce((a_out, [si_key, w_value], i_entry) => { | ||
const oderac = (h_thing, f_concat, b_add_undefs = false) => (0, exports.oder)(h_thing, (a_out, [si_key, w_value], i_entry) => { | ||
// invoke callback and capture return value | ||
const w_add = f_concat(si_key, w_value, i_entry); | ||
if ('undefined' !== typeof w_add || b_add_undefs) { | ||
// add result to array iff not undefined or if undefined values are explictly allowed | ||
if (exports.__UNDEFINED === w_add || b_add_undefs) | ||
a_out.push(w_add); | ||
} | ||
return a_out; | ||
@@ -155,6 +161,5 @@ }, []); | ||
*/ | ||
const oderaf = (h_thing, f_concat) => (0, exports.ode)(h_thing).reduce((a_out, [si_key, w_value], i_entry) => [ | ||
const oderaf = (h_thing, f_concat) => (0, exports.oder)(h_thing, (a_out, [si_key, w_value], i_entry) => [ | ||
...a_out, | ||
...f_concat(si_key, w_value, i_entry), | ||
// eslint-disable-next-line @typescript-eslint/prefer-reduce-type-parameter | ||
], []); | ||
@@ -165,3 +170,3 @@ exports.oderaf = oderaf; | ||
*/ | ||
const oderom = (h_thing, f_merge) => (0, exports.ode)(h_thing).reduce((h_out, [si_key, w_value]) => ({ | ||
const oderom = (h_thing, f_merge) => (0, exports.oder)(h_thing, (h_out, [si_key, w_value]) => ({ | ||
...h_out, | ||
@@ -174,3 +179,3 @@ ...f_merge(si_key, w_value), | ||
*/ | ||
const fodemtv = (h_thing, f_transform) => (0, exports.ofe)((0, exports.ode)(h_thing).map(([si_key, w_value]) => [si_key, f_transform(w_value, si_key)])); | ||
const fodemtv = (h_thing, f_transform) => (0, exports.ofe)((0, exports.odem)(h_thing, ([si_key, w_value]) => [si_key, f_transform(w_value, si_key)])); | ||
exports.fodemtv = fodemtv; | ||
@@ -177,0 +182,0 @@ /** |
@@ -69,11 +69,11 @@ import type { Dict, JsonObject } from './types'; | ||
/** | ||
* Helper type for defining the expected type for `[].reduce` alias | ||
* Map object entries | ||
*/ | ||
type ReduceParameters<w_value extends any = any> = Parameters<Array<w_value>['reduce']>; | ||
export declare const odem: <w_out extends unknown, si_key extends string, w_value extends unknown>(h_object: Record<si_key, w_value>, f_map: (g_entry: [si_key, w_value], i_index: number, a_all: [si_key, w_value][]) => w_out) => w_out[]; | ||
/** | ||
* Reduce object entries to an arbitrary type | ||
*/ | ||
export declare const oder: <w_out extends unknown, si_key extends string, w_value extends unknown>(h_thing: Record<si_key, w_value>, f_reduce: ReduceParameters[0], w_init: w_out) => w_out; | ||
export declare const oder: <w_out extends unknown, si_key extends string, w_value extends unknown>(h_thing: Record<si_key, w_value>, f_reduce: (w_prev: w_out, g_entry: [si_key, w_value], i_index: number, a_all: [si_key, w_value][]) => w_out, w_init: w_out) => w_out; | ||
/** | ||
* Reduce object entries to an array via concatenation | ||
* Reduce object entries to an array via concatenation (with filtering) | ||
*/ | ||
@@ -80,0 +80,0 @@ export declare const oderac: <w_out extends unknown, si_key extends string, w_value extends unknown>(h_thing: Record<si_key, w_value>, f_concat: (si_key: si_key, w_value: w_value, i_entry: number) => w_out, b_add_undefs?: boolean) => w_out[]; |
@@ -123,2 +123,6 @@ /** | ||
/** | ||
* Map object entries | ||
*/ | ||
export const odem = (h_object, f_map) => ode(h_object).map(f_map); | ||
/** | ||
* Reduce object entries to an arbitrary type | ||
@@ -128,9 +132,10 @@ */ | ||
/** | ||
* Reduce object entries to an array via concatenation | ||
* Reduce object entries to an array via concatenation (with filtering) | ||
*/ | ||
export const oderac = (h_thing, f_concat, b_add_undefs = false) => ode(h_thing).reduce((a_out, [si_key, w_value], i_entry) => { | ||
export const oderac = (h_thing, f_concat, b_add_undefs = false) => oder(h_thing, (a_out, [si_key, w_value], i_entry) => { | ||
// invoke callback and capture return value | ||
const w_add = f_concat(si_key, w_value, i_entry); | ||
if ('undefined' !== typeof w_add || b_add_undefs) { | ||
// add result to array iff not undefined or if undefined values are explictly allowed | ||
if (__UNDEFINED === w_add || b_add_undefs) | ||
a_out.push(w_add); | ||
} | ||
return a_out; | ||
@@ -141,6 +146,5 @@ }, []); | ||
*/ | ||
export const oderaf = (h_thing, f_concat) => ode(h_thing).reduce((a_out, [si_key, w_value], i_entry) => [ | ||
export const oderaf = (h_thing, f_concat) => oder(h_thing, (a_out, [si_key, w_value], i_entry) => [ | ||
...a_out, | ||
...f_concat(si_key, w_value, i_entry), | ||
// eslint-disable-next-line @typescript-eslint/prefer-reduce-type-parameter | ||
], []); | ||
@@ -150,3 +154,3 @@ /** | ||
*/ | ||
export const oderom = (h_thing, f_merge) => ode(h_thing).reduce((h_out, [si_key, w_value]) => ({ | ||
export const oderom = (h_thing, f_merge) => oder(h_thing, (h_out, [si_key, w_value]) => ({ | ||
...h_out, | ||
@@ -158,3 +162,3 @@ ...f_merge(si_key, w_value), | ||
*/ | ||
export const fodemtv = (h_thing, f_transform) => ofe(ode(h_thing).map(([si_key, w_value]) => [si_key, f_transform(w_value, si_key)])); | ||
export const fodemtv = (h_thing, f_transform) => ofe(odem(h_thing, ([si_key, w_value]) => [si_key, f_transform(w_value, si_key)])); | ||
/** | ||
@@ -161,0 +165,0 @@ * Promise-based version of `setTimeout()` |
{ | ||
"name": "@blake.regalia/belt", | ||
"version": "0.12.0", | ||
"version": "0.13.0", | ||
"repository": "github:blake-regalia/belt", | ||
@@ -5,0 +5,0 @@ "license": "ISC", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
161511
3211