Skip to content

Commit

Permalink
build: build and add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
yubaoquan committed May 2, 2024
1 parent 4201f2d commit 7ea19c1
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 3 deletions.
12 changes: 11 additions & 1 deletion cdn/radash.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,11 @@ const pick = (obj, keys2) => {
return acc;
}, {});
};
const pickBy = (obj, predicate = () => true) => {
if (!obj)
return {};
return pick(obj, Object.keys(obj).filter((key) => predicate(obj[key])));
};
const omit = (obj, keys2) => {
if (!obj)
return {};
Expand All @@ -708,6 +713,11 @@ const omit = (obj, keys2) => {
{ ...obj }
);
};
const omitBy = (obj, predicate = () => true) => {
if (!obj)
return {};
return omit(obj, Object.keys(obj).filter((key) => predicate(obj[key])));
};
const get = (value, path, defaultValue) => {
const segments = path.split(/[\.\[\]]/g);
let current = value;
Expand Down Expand Up @@ -937,4 +947,4 @@ const trim = (str, charsToTrim = " ") => {
return str.replace(regex, "");
};

export { all, alphabetical, assign, boil, callable, camel, capitalize, chain, clone, cluster, compose, construct, counting, crush, dash, debounce, defer, diff, draw, first, flat, fork, get, group, guard, inRange, intersects, invert, isArray, isDate, isEmpty, isEqual, isFloat, isFunction, isInt, isNumber, isObject, isPrimitive, isPromise, isString, isSymbol, iterate, keys, last, list, listify, lowerize, map, mapEntries, mapKeys, mapValues, max, memo, merge, min, objectify, omit, parallel, partial, partob, pascal, pick, proxied, random, range, reduce, replace, replaceOrAppend, retry, select, series, set, shake, shift, shuffle, sift, sleep, snake, sort, sum, template, throttle, title, toFloat, toInt, toggle, trim, tryit as try, tryit, uid, unique, upperize, zip, zipToObject };
export { all, alphabetical, assign, boil, callable, camel, capitalize, chain, clone, cluster, compose, construct, counting, crush, dash, debounce, defer, diff, draw, first, flat, fork, get, group, guard, inRange, intersects, invert, isArray, isDate, isEmpty, isEqual, isFloat, isFunction, isInt, isNumber, isObject, isPrimitive, isPromise, isString, isSymbol, iterate, keys, last, list, listify, lowerize, map, mapEntries, mapKeys, mapValues, max, memo, merge, min, objectify, omit, omitBy, parallel, partial, partob, pascal, pick, pickBy, proxied, random, range, reduce, replace, replaceOrAppend, retry, select, series, set, shake, shift, shuffle, sift, sleep, snake, sort, sum, template, throttle, title, toFloat, toInt, toggle, trim, tryit as try, tryit, uid, unique, upperize, zip, zipToObject };
12 changes: 12 additions & 0 deletions cdn/radash.js
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,11 @@ var radash = (function (exports) {
return acc;
}, {});
};
const pickBy = (obj, predicate = () => true) => {
if (!obj)
return {};
return pick(obj, Object.keys(obj).filter((key) => predicate(obj[key])));
};
const omit = (obj, keys2) => {
if (!obj)
return {};
Expand All @@ -711,6 +716,11 @@ var radash = (function (exports) {
{ ...obj }
);
};
const omitBy = (obj, predicate = () => true) => {
if (!obj)
return {};
return omit(obj, Object.keys(obj).filter((key) => predicate(obj[key])));
};
const get = (value, path, defaultValue) => {
const segments = path.split(/[\.\[\]]/g);
let current = value;
Expand Down Expand Up @@ -997,11 +1007,13 @@ var radash = (function (exports) {
exports.min = min;
exports.objectify = objectify;
exports.omit = omit;
exports.omitBy = omitBy;
exports.parallel = parallel;
exports.partial = partial;
exports.partob = partob;
exports.pascal = pascal;
exports.pick = pick;
exports.pickBy = pickBy;
exports.proxied = proxied;
exports.random = random;
exports.range = range;
Expand Down
2 changes: 1 addition & 1 deletion cdn/radash.min.js

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions docs/object/omit-by.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
title: omitBy
description: Omit unwanted attributes from an object by an identity function
group: Object
---

## Basic usage

Given an object and an identity function, returns a new object without any of the values which makes identity returns true.

```ts
import { omitBy } from 'radash'

const fish = {
name: 'Bass',
weight: 8,
source: 'lake',
brackish: false
}

omitBy(fish, v => v === 8) // => { name, source, brackish }
```
22 changes: 22 additions & 0 deletions docs/object/pick-by.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
title: pickBy
description: Pick only the desired attributes from an object
group: Object
---

## Basic usage

Given an object and an identity function, returns a new object with only the values which makes identity returns true.

```ts
import { pickBy } from 'radash'

const fish = {
name: 'Bass',
weight: 8,
source: 'lake',
barckish: false
}

pick(fish, v => v === 8) // => { weight }
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "radash",
"version": "12.1.0",
"version": "12.2.0",
"description": "Functional utility library - modern, simple, typed, powerful",
"main": "dist/cjs/index.cjs",
"module": "dist/esm/index.mjs",
Expand Down

0 comments on commit 7ea19c1

Please sign in to comment.