@ptolemy2002/ts-utils 2.4.0 → 2.5.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.
package/README.md CHANGED
@@ -133,6 +133,17 @@ This function takes a value of type `T` and a condition of type `OptionalValueCo
133
133
  #### Returns
134
134
  - `boolean` - Whether the value meets the condition.
135
135
 
136
+ ### omit<T, K extends keyof T>
137
+ #### Description
138
+ This function takes an object of type `T` and a list of keys `K` and returns a new object with all the keys in `K` removed.
139
+
140
+ #### Parameters
141
+ - `object` (`T`) - The object to omit keys from.
142
+ - `keys` (`K[]`) - The keys to omit from the object.
143
+
144
+ #### Returns
145
+ - `Omit<T, K>` - The object with the keys omitted.
146
+
136
147
  ## Peer Dependencies
137
148
  - `is-callable^1.2.7`
138
149
 
package/dist/index.d.ts CHANGED
@@ -54,3 +54,4 @@ export type BrandTag<B extends unknown[]> = {
54
54
  export type Branded<T, B extends unknown[]> = T & BrandTag<B>;
55
55
  export type WithBrand<T, B> = T extends BrandTag<unknown[]> ? (Contains<T[typeof __brand], B> extends true ? T : never) : never;
56
56
  export declare function brandValue<B extends unknown[], T>(value: T): Branded<T, B>;
57
+ export declare function omit<T extends object, K extends keyof T>(obj: T, ...keys: K[]): Omit<T, K>;
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AdvancedCondition = void 0;
4
4
  exports.valueConditionMatches = valueConditionMatches;
5
5
  exports.brandValue = brandValue;
6
+ exports.omit = omit;
6
7
  const isCallable = require("is-callable");
7
8
  class AdvancedCondition {
8
9
  constructor({ include = [], exclude = [], match = Object.is } = {}) {
@@ -44,3 +45,8 @@ function valueConditionMatches(value, condition) {
44
45
  function brandValue(value) {
45
46
  return value;
46
47
  }
48
+ function omit(obj, ...keys) {
49
+ const _ = { ...obj };
50
+ keys.forEach((key) => delete _[key]);
51
+ return _;
52
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ptolemy2002/ts-utils",
3
- "version": "2.4.0",
3
+ "version": "2.5.0",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",