@koine/utils 1.0.33 → 1.0.34

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/index.d.ts CHANGED
@@ -104,6 +104,8 @@ export * from "./navigateToParams";
104
104
  export * from "./navigateWithoutUrlParam";
105
105
  export * from "./normaliseUrlPathname";
106
106
  export * from "./normaliseUrl";
107
+ export * from "./objectPick";
108
+ export * from "./objectOmit";
107
109
  export * from "./pageview";
108
110
  export * from "./parseCookie";
109
111
  export * from "./parseURL";
@@ -133,5 +135,4 @@ export * from "./updateLinkParams";
133
135
  export * from "./updateUrlQueryParams";
134
136
  export * from "./uuid";
135
137
  export * from "./wait";
136
- export * from "./whitelistObject";
137
138
  export type { Primitive, Class, Constructor, TypedArray, ObservableLike, Except, Mutable, Merge, MergeExclusive, RequireAtLeastOne, RequireExactlyOne, RequireAllOrNone, RemoveIndexSignature, PartialDeep, ReadonlyDeep, LiteralUnion, Opaque, InvariantOf, SetOptional, SetRequired, ValueOf, ConditionalKeys, ConditionalPick, ConditionalExcept, UnionToIntersection, LiteralToPrimitive, Stringified, IterableElement, Entry, Entries, SetReturnType, Simplify, Get, StringKeyOf, Schema, Jsonify, JsonPrimitive, JsonObject, JsonArray, JsonValue, Promisable, AsyncReturnType, Asyncify, Trim, Split, Includes, Join, LastArrayElement, FixedLengthArray, MultidimensionalArray, MultidimensionalReadonlyArray, PositiveInfinity, NegativeInfinity, Finite, Integer, Float, NegativeFloat, Negative, NonNegative, NegativeInteger, NonNegativeInteger, CamelCase, CamelCasedProperties, CamelCasedPropertiesDeep, KebabCase, KebabCasedProperties, KebabCasedPropertiesDeep, PascalCase, PascalCasedProperties, PascalCasedPropertiesDeep, SnakeCase, SnakeCasedProperties, SnakeCasedPropertiesDeep, ScreamingSnakeCase, DelimiterCase, DelimiterCasedProperties, DelimiterCasedPropertiesDeep, PackageJson, TsConfigJson, } from "type-fest";
package/index.js CHANGED
@@ -105,6 +105,8 @@ export * from "./navigateToParams";
105
105
  export * from "./navigateWithoutUrlParam";
106
106
  export * from "./normaliseUrlPathname";
107
107
  export * from "./normaliseUrl";
108
+ export * from "./objectPick";
109
+ export * from "./objectOmit";
108
110
  export * from "./pageview";
109
111
  export * from "./parseCookie";
110
112
  export * from "./parseURL";
@@ -134,4 +136,3 @@ export * from "./updateLinkParams";
134
136
  export * from "./updateUrlQueryParams";
135
137
  export * from "./uuid";
136
138
  export * from "./wait";
137
- export * from "./whitelistObject";
package/node/index.js CHANGED
@@ -108,6 +108,8 @@ tslib_1.__exportStar(require("./navigateToParams"), exports);
108
108
  tslib_1.__exportStar(require("./navigateWithoutUrlParam"), exports);
109
109
  tslib_1.__exportStar(require("./normaliseUrlPathname"), exports);
110
110
  tslib_1.__exportStar(require("./normaliseUrl"), exports);
111
+ tslib_1.__exportStar(require("./objectPick"), exports);
112
+ tslib_1.__exportStar(require("./objectOmit"), exports);
111
113
  tslib_1.__exportStar(require("./pageview"), exports);
112
114
  tslib_1.__exportStar(require("./parseCookie"), exports);
113
115
  tslib_1.__exportStar(require("./parseURL"), exports);
@@ -137,4 +139,3 @@ tslib_1.__exportStar(require("./updateLinkParams"), exports);
137
139
  tslib_1.__exportStar(require("./updateUrlQueryParams"), exports);
138
140
  tslib_1.__exportStar(require("./uuid"), exports);
139
141
  tslib_1.__exportStar(require("./wait"), exports);
140
- tslib_1.__exportStar(require("./whitelistObject"), exports);
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.objectOmit = void 0;
4
+ /**
5
+ * Omit object properties by removing the given keys, it returns a
6
+ * new object.
7
+ *
8
+ * NOTE: most of the time using a normal [destructuring assignment](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment) is enough,
9
+ * use this utility only when it makes sense.
10
+ *
11
+ * @category objects
12
+ */
13
+ function objectOmit(object, keys) {
14
+ return Object.keys(object).reduce(function (output, key) {
15
+ if (!keys.includes(key)) {
16
+ output[key] =
17
+ object[key];
18
+ }
19
+ return output;
20
+ }, {});
21
+ }
22
+ exports.objectOmit = objectOmit;
23
+ exports.default = objectOmit;
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.whitelistObject = void 0;
3
+ exports.objectPick = void 0;
4
4
  /**
5
- * Whitelist an object properties by selecting only the given keys, it returns a
5
+ * Pick object properties by selecting only the given keys, it returns a
6
6
  * new object.
7
7
  *
8
8
  * @category objects
9
9
  */
10
- function whitelistObject(object, keys) {
10
+ function objectPick(object, keys) {
11
11
  var output = {};
12
12
  var len = keys.length;
13
13
  while (len--) {
@@ -15,5 +15,5 @@ function whitelistObject(object, keys) {
15
15
  }
16
16
  return output;
17
17
  }
18
- exports.whitelistObject = whitelistObject;
19
- exports.default = whitelistObject;
18
+ exports.objectPick = objectPick;
19
+ exports.default = objectPick;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Omit object properties by removing the given keys, it returns a
3
+ * new object.
4
+ *
5
+ * NOTE: most of the time using a normal [destructuring assignment](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment) is enough,
6
+ * use this utility only when it makes sense.
7
+ *
8
+ * @category objects
9
+ */
10
+ export declare function objectOmit<T extends object, Keys extends (keyof T)[]>(object: T, keys: Keys): Omit<T, Keys[number]>;
11
+ export default objectOmit;
package/objectOmit.js ADDED
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Omit object properties by removing the given keys, it returns a
3
+ * new object.
4
+ *
5
+ * NOTE: most of the time using a normal [destructuring assignment](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment) is enough,
6
+ * use this utility only when it makes sense.
7
+ *
8
+ * @category objects
9
+ */
10
+ export function objectOmit(object, keys) {
11
+ return Object.keys(object).reduce(function (output, key) {
12
+ if (!keys.includes(key)) {
13
+ output[key] =
14
+ object[key];
15
+ }
16
+ return output;
17
+ }, {});
18
+ }
19
+ export default objectOmit;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Pick object properties by selecting only the given keys, it returns a
3
+ * new object.
4
+ *
5
+ * @category objects
6
+ */
7
+ export declare function objectPick<T extends object, Keys extends (keyof T)[]>(object: T, keys: Keys): Pick<T, Keys[number]>;
8
+ export default objectPick;
package/objectPick.js ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Pick object properties by selecting only the given keys, it returns a
3
+ * new object.
4
+ *
5
+ * @category objects
6
+ */
7
+ export function objectPick(object, keys) {
8
+ var output = {};
9
+ var len = keys.length;
10
+ while (len--) {
11
+ output[keys[len]] = object[keys[len]];
12
+ }
13
+ return output;
14
+ }
15
+ export default objectPick;
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "peerDependencies": {
8
8
  "tslib": "^2.4.0"
9
9
  },
10
- "version": "1.0.33",
10
+ "version": "1.0.34",
11
11
  "module": "./index.js",
12
12
  "types": "./index.d.ts"
13
13
  }