@koine/utils 1.0.31 → 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 +2 -2
- package/index.js +2 -2
- package/isServer.js +3 -3
- package/node/index.js +2 -2
- package/node/isServer.js +3 -3
- package/node/objectOmit.js +23 -0
- package/node/{whitelistObject.js → objectPick.js} +5 -5
- package/objectOmit.d.ts +11 -0
- package/objectOmit.js +19 -0
- package/objectPick.d.ts +8 -0
- package/objectPick.js +15 -0
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -49,7 +49,6 @@ export * from "./getUrlHashParams";
|
|
|
49
49
|
export * from "./getUrlHashPathname";
|
|
50
50
|
export * from "./getUrlPathnameParts";
|
|
51
51
|
export * from "./getUrlQueryParams";
|
|
52
|
-
export * from "./index";
|
|
53
52
|
export * from "./isAnyObject";
|
|
54
53
|
export * from "./isArray";
|
|
55
54
|
export * from "./isBlob";
|
|
@@ -105,6 +104,8 @@ export * from "./navigateToParams";
|
|
|
105
104
|
export * from "./navigateWithoutUrlParam";
|
|
106
105
|
export * from "./normaliseUrlPathname";
|
|
107
106
|
export * from "./normaliseUrl";
|
|
107
|
+
export * from "./objectPick";
|
|
108
|
+
export * from "./objectOmit";
|
|
108
109
|
export * from "./pageview";
|
|
109
110
|
export * from "./parseCookie";
|
|
110
111
|
export * from "./parseURL";
|
|
@@ -134,5 +135,4 @@ export * from "./updateLinkParams";
|
|
|
134
135
|
export * from "./updateUrlQueryParams";
|
|
135
136
|
export * from "./uuid";
|
|
136
137
|
export * from "./wait";
|
|
137
|
-
export * from "./whitelistObject";
|
|
138
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
|
@@ -50,7 +50,6 @@ export * from "./getUrlHashParams";
|
|
|
50
50
|
export * from "./getUrlHashPathname";
|
|
51
51
|
export * from "./getUrlPathnameParts";
|
|
52
52
|
export * from "./getUrlQueryParams";
|
|
53
|
-
export * from "./index";
|
|
54
53
|
export * from "./isAnyObject";
|
|
55
54
|
export * from "./isArray";
|
|
56
55
|
export * from "./isBlob";
|
|
@@ -106,6 +105,8 @@ export * from "./navigateToParams";
|
|
|
106
105
|
export * from "./navigateWithoutUrlParam";
|
|
107
106
|
export * from "./normaliseUrlPathname";
|
|
108
107
|
export * from "./normaliseUrl";
|
|
108
|
+
export * from "./objectPick";
|
|
109
|
+
export * from "./objectOmit";
|
|
109
110
|
export * from "./pageview";
|
|
110
111
|
export * from "./parseCookie";
|
|
111
112
|
export * from "./parseURL";
|
|
@@ -135,4 +136,3 @@ export * from "./updateLinkParams";
|
|
|
135
136
|
export * from "./updateUrlQueryParams";
|
|
136
137
|
export * from "./uuid";
|
|
137
138
|
export * from "./wait";
|
|
138
|
-
export * from "./whitelistObject";
|
package/isServer.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import isBrowser from "./isBrowser";
|
|
2
2
|
/**
|
|
3
3
|
* @category ssr
|
|
4
4
|
* @category is
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
|
-
export
|
|
6
|
+
export var isServer = !isBrowser;
|
|
7
|
+
// export const isServer = typeof window === "undefined";
|
|
8
8
|
// export const isServer = () => typeof window === "undefined";
|
|
9
9
|
export default isServer;
|
package/node/index.js
CHANGED
|
@@ -53,7 +53,6 @@ tslib_1.__exportStar(require("./getUrlHashParams"), exports);
|
|
|
53
53
|
tslib_1.__exportStar(require("./getUrlHashPathname"), exports);
|
|
54
54
|
tslib_1.__exportStar(require("./getUrlPathnameParts"), exports);
|
|
55
55
|
tslib_1.__exportStar(require("./getUrlQueryParams"), exports);
|
|
56
|
-
tslib_1.__exportStar(require("./index"), exports);
|
|
57
56
|
tslib_1.__exportStar(require("./isAnyObject"), exports);
|
|
58
57
|
tslib_1.__exportStar(require("./isArray"), exports);
|
|
59
58
|
tslib_1.__exportStar(require("./isBlob"), exports);
|
|
@@ -109,6 +108,8 @@ tslib_1.__exportStar(require("./navigateToParams"), exports);
|
|
|
109
108
|
tslib_1.__exportStar(require("./navigateWithoutUrlParam"), exports);
|
|
110
109
|
tslib_1.__exportStar(require("./normaliseUrlPathname"), exports);
|
|
111
110
|
tslib_1.__exportStar(require("./normaliseUrl"), exports);
|
|
111
|
+
tslib_1.__exportStar(require("./objectPick"), exports);
|
|
112
|
+
tslib_1.__exportStar(require("./objectOmit"), exports);
|
|
112
113
|
tslib_1.__exportStar(require("./pageview"), exports);
|
|
113
114
|
tslib_1.__exportStar(require("./parseCookie"), exports);
|
|
114
115
|
tslib_1.__exportStar(require("./parseURL"), exports);
|
|
@@ -138,4 +139,3 @@ tslib_1.__exportStar(require("./updateLinkParams"), exports);
|
|
|
138
139
|
tslib_1.__exportStar(require("./updateUrlQueryParams"), exports);
|
|
139
140
|
tslib_1.__exportStar(require("./uuid"), exports);
|
|
140
141
|
tslib_1.__exportStar(require("./wait"), exports);
|
|
141
|
-
tslib_1.__exportStar(require("./whitelistObject"), exports);
|
package/node/isServer.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// import isBrowser from "./isBrowser";
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.isServer = void 0;
|
|
4
|
+
var isBrowser_1 = require("./isBrowser");
|
|
5
5
|
/**
|
|
6
6
|
* @category ssr
|
|
7
7
|
* @category is
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
exports.isServer = !isBrowser_1.default;
|
|
10
|
+
// export const isServer = typeof window === "undefined";
|
|
11
11
|
// export const isServer = () => typeof window === "undefined";
|
|
12
12
|
exports.default = exports.isServer;
|
|
@@ -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.
|
|
3
|
+
exports.objectPick = void 0;
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
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
|
|
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.
|
|
19
|
-
exports.default =
|
|
18
|
+
exports.objectPick = objectPick;
|
|
19
|
+
exports.default = objectPick;
|
package/objectOmit.d.ts
ADDED
|
@@ -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;
|
package/objectPick.d.ts
ADDED
|
@@ -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;
|