@rimbu/base 0.8.0 → 0.9.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 +26 -15
- package/dist/main/arr.js +3 -3
- package/dist/main/arr.js.map +1 -1
- package/dist/main/index.js +5 -7
- package/dist/main/index.js.map +1 -1
- package/dist/main/internal.js +1 -1
- package/dist/main/internal.js.map +1 -1
- package/dist/main/plain-object.js +33 -0
- package/dist/main/plain-object.js.map +1 -0
- package/dist/main/rimbu-error.js +4 -4
- package/dist/main/rimbu-error.js.map +1 -1
- package/dist/module/index.js +4 -4
- package/dist/module/index.js.map +1 -1
- package/dist/module/plain-object.js +28 -0
- package/dist/module/plain-object.js.map +1 -0
- package/dist/types/index.d.ts +4 -4
- package/dist/types/plain-object.d.ts +33 -0
- package/package.json +4 -4
- package/src/index.ts +4 -5
- package/src/plain-object.ts +69 -0
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ This package contains mostly utilities to implement the other Rimbu collections.
|
|
|
8
8
|
|
|
9
9
|
Most important are the exported `Arr` methods that are used at the basis of all the block-based data structures. These methods should be as correct and efficient as possible.
|
|
10
10
|
|
|
11
|
-
For complete documentation please visit the _[Rimbu Docs](https://rimbu.org)_.
|
|
11
|
+
For complete documentation please visit the _[Rimbu Docs](https://rimbu.org)_ or the _[Rimbu API Docs](https://rimbu.org/api)_
|
|
12
12
|
|
|
13
13
|
## Installation
|
|
14
14
|
|
|
@@ -22,29 +22,40 @@ or
|
|
|
22
22
|
|
|
23
23
|
### Deno
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
For Deno, the following approach is recommended:
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
> export * from 'https://deno.land/x/rimbu/base/mod.ts';
|
|
29
|
-
> ```
|
|
27
|
+
In the root folder of your project, create or edit a file called `import_map.json` with the following contents (where you should replace `x.y.z` with the desired version of Rimbu):
|
|
30
28
|
|
|
31
|
-
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"imports": {
|
|
32
|
+
"@rimbu/": "https://deno.land/x/rimbu@x.y.z/"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Note: The trailing slashes are important!**
|
|
38
|
+
|
|
39
|
+
In this way you can use relative imports from Rimbu in your code, like so:
|
|
32
40
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
41
|
+
```ts
|
|
42
|
+
import { List } from '@rimbu/core/mod.ts';
|
|
43
|
+
import { HashMap } from '@rimbu/hashed/mod.ts';
|
|
44
|
+
```
|
|
36
45
|
|
|
37
|
-
|
|
46
|
+
Note that for sub-packages, due to conversion limitations it is needed to import the `index.ts` instead of `mod.ts`, like so:
|
|
38
47
|
|
|
39
48
|
```ts
|
|
40
|
-
import {
|
|
49
|
+
import { HashMap } from '@rimbu/hashed/map/index.ts';
|
|
41
50
|
```
|
|
42
51
|
|
|
43
|
-
|
|
52
|
+
To run your script (let's assume the entry point is in `src/main.ts`):
|
|
53
|
+
|
|
54
|
+
`deno run --import-map import_map.json src/main.ts`
|
|
44
55
|
|
|
45
|
-
|
|
56
|
+
Because Rimbu uses advanced types, this may slow down the type checking part when running your code. If you're able to rely on your code editor to provide type errors, you can skip the Deno type check using the `--no-check` flag:
|
|
46
57
|
|
|
47
|
-
|
|
58
|
+
`deno run --import-map import_map.json --no-check src/main.ts`
|
|
48
59
|
|
|
49
60
|
## Usage
|
|
50
61
|
|
|
@@ -69,7 +80,7 @@ Feel very welcome to contribute to further improve Rimbu. Please read our [Contr
|
|
|
69
80
|
|
|
70
81
|
## Contributors
|
|
71
82
|
|
|
72
|
-
<img src = "https://contrib.rocks/image?repo=
|
|
83
|
+
<img src = "https://contrib.rocks/image?repo=rimbu-org/rimbu"/>
|
|
73
84
|
|
|
74
85
|
Made with [contributors-img](https://contrib.rocks).
|
|
75
86
|
|
package/dist/main/arr.js
CHANGED
|
@@ -46,9 +46,9 @@ function forEach(array, f, state, reversed) {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
else {
|
|
49
|
-
var
|
|
49
|
+
var length_1 = array.length;
|
|
50
50
|
var i = -1;
|
|
51
|
-
while (!state.halted && ++i <
|
|
51
|
+
while (!state.halted && ++i < length_1) {
|
|
52
52
|
f(array[i], state.nextIndex(), halt);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
@@ -143,7 +143,7 @@ function splice(arr, start, deleteCount) {
|
|
|
143
143
|
items[_i - 3] = arguments[_i];
|
|
144
144
|
}
|
|
145
145
|
var clone = arr.slice();
|
|
146
|
-
clone.splice.apply(clone,
|
|
146
|
+
clone.splice.apply(clone, tslib_1.__spreadArray([start, deleteCount], tslib_1.__read(items), false));
|
|
147
147
|
return clone;
|
|
148
148
|
}
|
|
149
149
|
exports.splice = splice;
|
package/dist/main/arr.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arr.js","sourceRoot":"","sources":["../../src/arr.ts"],"names":[],"mappings":";;;;AAAA,wCAAqE;AAErE,4DAA4D;AAC5D,SAAgB,MAAM,CAAI,KAAmB,EAAE,KAAQ;IACrD,IAAM,KAAK,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;IAC5B,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAClB,OAAO,KAAyB,CAAC;AACnC,CAAC;AAJD,wBAIC;AAED,iHAAiH;AACjH,SAAgB,MAAM,CACpB,KAAmB,EACnB,MAAoB;IAEpB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,MAAM,CAAC;IACtC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACtC,OAAO,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC9B,CAAC;AAPD,wBAOC;AAED,uGAAuG;AACvG,SAAgB,OAAO,CACrB,KAAmB,EACnB,KAAS,EACT,GAAsB;IADtB,sBAAA,EAAA,SAAS;IACT,o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AG,GAAG,CAAC,GAAG,CAAC,CAAC;KACvB;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAND,gCAMC;AAED,+GAA+G;AAC/G,0CAA0C;AAC1C,SAAgB,SAAS,CACvB,GAAiB,EACjB,CAAkC;IAElC,IAAM,MAAM,GAAS,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAEvC,KAAK,IAAM,GAAG,IAAI,GAAG,EAAE;QACrB,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,GAAU,CAAC,CAAC;KACvC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAXD,8BAWC"}
|
package/dist/main/index.js
CHANGED
|
@@ -2,11 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RimbuError = exports.Entry = exports.Arr = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
|
-
|
|
6
|
-
exports.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
exports.RimbuError = RimbuError;
|
|
11
|
-
(0, tslib_1.__exportStar)(require("./internal"), exports);
|
|
5
|
+
exports.Arr = tslib_1.__importStar(require("./arr"));
|
|
6
|
+
exports.Entry = tslib_1.__importStar(require("./entry"));
|
|
7
|
+
exports.RimbuError = tslib_1.__importStar(require("./rimbu-error"));
|
|
8
|
+
tslib_1.__exportStar(require("./plain-object"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./internal"), exports);
|
|
12
10
|
//# sourceMappingURL=index.js.map
|
package/dist/main/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAAA,qDAA6B;AAC7B,yDAAiC;AACjC,oEAA4C;AAC5C,yDAA+B;AAE/B,qDAA2B"}
|
package/dist/main/internal.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../src/internal.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../src/internal.ts"],"names":[],"mappings":";;;AAAA,kDAAwB"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isIterable = exports.isPlainObj = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Companion function to the `IsRecord<T>` type that checks whether the given object is a pure
|
|
6
|
+
* data object.
|
|
7
|
+
* @param obj - the object to check
|
|
8
|
+
* @returns true if the given object is a pure data object
|
|
9
|
+
* @note does not check whether a record's properties are not functions
|
|
10
|
+
*/
|
|
11
|
+
function isPlainObj(obj) {
|
|
12
|
+
if (undefined === obj ||
|
|
13
|
+
null === obj ||
|
|
14
|
+
typeof obj !== 'object' ||
|
|
15
|
+
(obj.constructor instanceof Function &&
|
|
16
|
+
obj.constructor.name !== 'Object') ||
|
|
17
|
+
Symbol.iterator in obj ||
|
|
18
|
+
Symbol.asyncIterator in obj) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
var prototype = Object.getPrototypeOf(obj);
|
|
22
|
+
return null === prototype || prototype === Object.prototype;
|
|
23
|
+
}
|
|
24
|
+
exports.isPlainObj = isPlainObj;
|
|
25
|
+
/**
|
|
26
|
+
* Returns true if the given object is Iterable
|
|
27
|
+
* @param obj - the object to check
|
|
28
|
+
*/
|
|
29
|
+
function isIterable(obj) {
|
|
30
|
+
return obj !== null && typeof obj === 'object' && Symbol.iterator in obj;
|
|
31
|
+
}
|
|
32
|
+
exports.isIterable = isIterable;
|
|
33
|
+
//# sourceMappingURL=plain-object.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plain-object.js","sourceRoot":"","sources":["../../src/plain-object.ts"],"names":[],"mappings":";;;AAqCA;;;;;;GAMG;AACH,SAAgB,UAAU,CAAC,GAAQ;IACjC,IACE,SAAS,KAAK,GAAG;QACjB,IAAI,KAAK,GAAG;QACZ,OAAO,GAAG,KAAK,QAAQ;QACvB,CAAC,GAAG,CAAC,WAAW,YAAY,QAAQ;YAClC,GAAG,CAAC,WAAW,CAAC,IAAI,KAAK,QAAQ,CAAC;QACpC,MAAM,CAAC,QAAQ,IAAI,GAAG;QACtB,MAAM,CAAC,aAAa,IAAI,GAAG,EAC3B;QACA,OAAO,KAAK,CAAC;KACd;IAED,IAAM,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IAE7C,OAAO,IAAI,KAAK,SAAS,IAAI,SAAS,KAAK,MAAM,CAAC,SAAS,CAAC;AAC9D,CAAC;AAhBD,gCAgBC;AAED;;;GAGG;AACH,SAAgB,UAAU,CAAC,GAAQ;IACjC,OAAO,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,IAAI,GAAG,CAAC;AAC3E,CAAC;AAFD,gCAEC"}
|
package/dist/main/rimbu-error.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.throwInvalidUsageError = exports.throwInvalidStateError = exports.throwM
|
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
var common_1 = require("@rimbu/common");
|
|
6
6
|
var EmptyCollectionAssumedNonEmptyError = /** @class */ (function (_super) {
|
|
7
|
-
|
|
7
|
+
tslib_1.__extends(EmptyCollectionAssumedNonEmptyError, _super);
|
|
8
8
|
function EmptyCollectionAssumedNonEmptyError() {
|
|
9
9
|
return _super.call(this, 'empty collection was assumbed to be non-empty') || this;
|
|
10
10
|
}
|
|
@@ -12,7 +12,7 @@ var EmptyCollectionAssumedNonEmptyError = /** @class */ (function (_super) {
|
|
|
12
12
|
}(common_1.ErrBase.CustomError));
|
|
13
13
|
exports.EmptyCollectionAssumedNonEmptyError = EmptyCollectionAssumedNonEmptyError;
|
|
14
14
|
var ModifiedBuilderWhileLoopingOverItError = /** @class */ (function (_super) {
|
|
15
|
-
|
|
15
|
+
tslib_1.__extends(ModifiedBuilderWhileLoopingOverItError, _super);
|
|
16
16
|
function ModifiedBuilderWhileLoopingOverItError() {
|
|
17
17
|
return _super.call(this, 'an attempt was made to modify a builder while looping over it') || this;
|
|
18
18
|
}
|
|
@@ -20,7 +20,7 @@ var ModifiedBuilderWhileLoopingOverItError = /** @class */ (function (_super) {
|
|
|
20
20
|
}(common_1.ErrBase.CustomError));
|
|
21
21
|
exports.ModifiedBuilderWhileLoopingOverItError = ModifiedBuilderWhileLoopingOverItError;
|
|
22
22
|
var InvalidStateError = /** @class */ (function (_super) {
|
|
23
|
-
|
|
23
|
+
tslib_1.__extends(InvalidStateError, _super);
|
|
24
24
|
function InvalidStateError() {
|
|
25
25
|
return _super.call(this, "something happend that shouldn't happen, please consider creating an issue") || this;
|
|
26
26
|
}
|
|
@@ -28,7 +28,7 @@ var InvalidStateError = /** @class */ (function (_super) {
|
|
|
28
28
|
}(common_1.ErrBase.CustomError));
|
|
29
29
|
exports.InvalidStateError = InvalidStateError;
|
|
30
30
|
var InvalidUsageError = /** @class */ (function (_super) {
|
|
31
|
-
|
|
31
|
+
tslib_1.__extends(InvalidUsageError, _super);
|
|
32
32
|
function InvalidUsageError() {
|
|
33
33
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
34
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rimbu-error.js","sourceRoot":"","sources":["../../src/rimbu-error.ts"],"names":[],"mappings":";;;;AAAA,wCAAwC;AAExC;IAAyD
|
|
1
|
+
{"version":3,"file":"rimbu-error.js","sourceRoot":"","sources":["../../src/rimbu-error.ts"],"names":[],"mappings":";;;;AAAA,wCAAwC;AAExC;IAAyD,+DAAmB;IAC1E;eACE,kBAAM,+CAA+C,CAAC;IACxD,CAAC;IACH,0CAAC;AAAD,CAAC,AAJD,CAAyD,gBAAO,CAAC,WAAW,GAI3E;AAJY,kFAAmC;AAMhD;IAA4D,kEAAmB;IAC7E;eACE,kBAAM,+DAA+D,CAAC;IACxE,CAAC;IACH,6CAAC;AAAD,CAAC,AAJD,CAA4D,gBAAO,CAAC,WAAW,GAI9E;AAJY,wFAAsC;AAMnD;IAAuC,6CAAmB;IACxD;eACE,kBACE,4EAA4E,CAC7E;IACH,CAAC;IACH,wBAAC;AAAD,CAAC,AAND,CAAuC,gBAAO,CAAC,WAAW,GAMzD;AANY,8CAAiB;AAQ9B;IAAuC,6CAAmB;IAA1D;;IAA4D,CAAC;IAAD,wBAAC;AAAD,CAAC,AAA7D,CAAuC,gBAAO,CAAC,WAAW,GAAG;AAAhD,8CAAiB;AAE9B,SAAgB,wCAAwC;IACtD,MAAM,IAAI,mCAAmC,EAAE,CAAC;AAClD,CAAC;AAFD,4FAEC;AAED,SAAgB,2CAA2C;IACzD,MAAM,IAAI,sCAAsC,EAAE,CAAC;AACrD,CAAC;AAFD,kGAEC;AAED,SAAgB,sBAAsB;IACpC,MAAM,IAAI,iBAAiB,EAAE,CAAC;AAChC,CAAC;AAFD,wDAEC;AAED,SAAgB,sBAAsB,CAAC,GAAW;IAChD,MAAM,IAAI,iBAAiB,CAAC,GAAG,CAAC,CAAC;AACnC,CAAC;AAFD,wDAEC"}
|
package/dist/module/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export
|
|
1
|
+
export * as Arr from './arr';
|
|
2
|
+
export * as Entry from './entry';
|
|
3
|
+
export * as RimbuError from './rimbu-error';
|
|
4
|
+
export * from './plain-object';
|
|
5
5
|
export * from './internal';
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
package/dist/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAC7B,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,UAAU,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAC7B,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,UAAU,MAAM,eAAe,CAAC;AAC5C,cAAc,gBAAgB,CAAC;AAE/B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Companion function to the `IsRecord<T>` type that checks whether the given object is a pure
|
|
3
|
+
* data object.
|
|
4
|
+
* @param obj - the object to check
|
|
5
|
+
* @returns true if the given object is a pure data object
|
|
6
|
+
* @note does not check whether a record's properties are not functions
|
|
7
|
+
*/
|
|
8
|
+
export function isPlainObj(obj) {
|
|
9
|
+
if (undefined === obj ||
|
|
10
|
+
null === obj ||
|
|
11
|
+
typeof obj !== 'object' ||
|
|
12
|
+
(obj.constructor instanceof Function &&
|
|
13
|
+
obj.constructor.name !== 'Object') ||
|
|
14
|
+
Symbol.iterator in obj ||
|
|
15
|
+
Symbol.asyncIterator in obj) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
const prototype = Object.getPrototypeOf(obj);
|
|
19
|
+
return null === prototype || prototype === Object.prototype;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Returns true if the given object is Iterable
|
|
23
|
+
* @param obj - the object to check
|
|
24
|
+
*/
|
|
25
|
+
export function isIterable(obj) {
|
|
26
|
+
return obj !== null && typeof obj === 'object' && Symbol.iterator in obj;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=plain-object.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plain-object.js","sourceRoot":"","sources":["../../src/plain-object.ts"],"names":[],"mappings":"AAqCA;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,GAAQ;IACjC,IACE,SAAS,KAAK,GAAG;QACjB,IAAI,KAAK,GAAG;QACZ,OAAO,GAAG,KAAK,QAAQ;QACvB,CAAC,GAAG,CAAC,WAAW,YAAY,QAAQ;YAClC,GAAG,CAAC,WAAW,CAAC,IAAI,KAAK,QAAQ,CAAC;QACpC,MAAM,CAAC,QAAQ,IAAI,GAAG;QACtB,MAAM,CAAC,aAAa,IAAI,GAAG,EAC3B;QACA,OAAO,KAAK,CAAC;KACd;IAED,MAAM,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IAE7C,OAAO,IAAI,KAAK,SAAS,IAAI,SAAS,KAAK,MAAM,CAAC,SAAS,CAAC;AAC9D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,GAAQ;IACjC,OAAO,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,IAAI,GAAG,CAAC;AAC3E,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export
|
|
1
|
+
export * as Arr from './arr';
|
|
2
|
+
export * as Entry from './entry';
|
|
3
|
+
export * as RimbuError from './rimbu-error';
|
|
4
|
+
export * from './plain-object';
|
|
5
5
|
export * from './internal';
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Matches any type of function
|
|
3
|
+
*/
|
|
4
|
+
export declare type AnyFunc = (...args: any[]) => any;
|
|
5
|
+
/**
|
|
6
|
+
* A predicate type for any record that resolves to true if any of the record
|
|
7
|
+
* properties is a function, false otherwise.
|
|
8
|
+
* This is useful to have a coarse discrimination between pure data objects and class instances.
|
|
9
|
+
*/
|
|
10
|
+
export declare type IsObjWithoutFunctions<T extends Record<any, any>> = AnyFunc extends T[keyof T] ? false : true;
|
|
11
|
+
/**
|
|
12
|
+
* A predicate type that resolves to true if the given type satisfies:
|
|
13
|
+
* - it is an object type (not a primitive)
|
|
14
|
+
* - it is not a function
|
|
15
|
+
* - it is not iterable
|
|
16
|
+
* - it does not have any properties that are functions
|
|
17
|
+
* Otherwise, it resolves to false
|
|
18
|
+
*/
|
|
19
|
+
export declare type IsPlainObj<T> = T extends null | undefined | number | string | boolean | bigint | symbol | AnyFunc | Iterable<unknown> | AsyncIterable<unknown> ? false : IsObjWithoutFunctions<T>;
|
|
20
|
+
export declare type PlainObj<T> = IsPlainObj<T> extends true ? T : never;
|
|
21
|
+
/**
|
|
22
|
+
* Companion function to the `IsRecord<T>` type that checks whether the given object is a pure
|
|
23
|
+
* data object.
|
|
24
|
+
* @param obj - the object to check
|
|
25
|
+
* @returns true if the given object is a pure data object
|
|
26
|
+
* @note does not check whether a record's properties are not functions
|
|
27
|
+
*/
|
|
28
|
+
export declare function isPlainObj(obj: any): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Returns true if the given object is Iterable
|
|
31
|
+
* @param obj - the object to check
|
|
32
|
+
*/
|
|
33
|
+
export declare function isIterable(obj: any): obj is Iterable<unknown>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rimbu/base",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Utilities to implement Rimbu collections",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"array",
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
},
|
|
52
52
|
"sideEffects": false,
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@rimbu/common": "^0.9.
|
|
55
|
-
"tslib": "^2.
|
|
54
|
+
"@rimbu/common": "^0.9.3",
|
|
55
|
+
"tslib": "^2.4.0"
|
|
56
56
|
},
|
|
57
57
|
"publishConfig": {
|
|
58
58
|
"access": "public"
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"index": "src/index.ts",
|
|
62
62
|
"replacer": "../../config/denoify-rimbu-replacer.js"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "4efaf8c469d606381517984436383fd6b1b61ec0"
|
|
65
65
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export { Arr, Entry, RimbuError };
|
|
1
|
+
export * as Arr from './arr';
|
|
2
|
+
export * as Entry from './entry';
|
|
3
|
+
export * as RimbuError from './rimbu-error';
|
|
4
|
+
export * from './plain-object';
|
|
6
5
|
|
|
7
6
|
export * from './internal';
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Matches any type of function
|
|
3
|
+
*/
|
|
4
|
+
export type AnyFunc = (...args: any[]) => any;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A predicate type for any record that resolves to true if any of the record
|
|
8
|
+
* properties is a function, false otherwise.
|
|
9
|
+
* This is useful to have a coarse discrimination between pure data objects and class instances.
|
|
10
|
+
*/
|
|
11
|
+
export type IsObjWithoutFunctions<T extends Record<any, any>> =
|
|
12
|
+
AnyFunc extends T[keyof T] ? false : true;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* A predicate type that resolves to true if the given type satisfies:
|
|
16
|
+
* - it is an object type (not a primitive)
|
|
17
|
+
* - it is not a function
|
|
18
|
+
* - it is not iterable
|
|
19
|
+
* - it does not have any properties that are functions
|
|
20
|
+
* Otherwise, it resolves to false
|
|
21
|
+
*/
|
|
22
|
+
export type IsPlainObj<T> = T extends
|
|
23
|
+
| null
|
|
24
|
+
| undefined
|
|
25
|
+
| number
|
|
26
|
+
| string
|
|
27
|
+
| boolean
|
|
28
|
+
| bigint
|
|
29
|
+
| symbol
|
|
30
|
+
| AnyFunc
|
|
31
|
+
| Iterable<unknown>
|
|
32
|
+
| AsyncIterable<unknown>
|
|
33
|
+
? false
|
|
34
|
+
: IsObjWithoutFunctions<T>;
|
|
35
|
+
|
|
36
|
+
export type PlainObj<T> = IsPlainObj<T> extends true ? T : never;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Companion function to the `IsRecord<T>` type that checks whether the given object is a pure
|
|
40
|
+
* data object.
|
|
41
|
+
* @param obj - the object to check
|
|
42
|
+
* @returns true if the given object is a pure data object
|
|
43
|
+
* @note does not check whether a record's properties are not functions
|
|
44
|
+
*/
|
|
45
|
+
export function isPlainObj(obj: any): boolean {
|
|
46
|
+
if (
|
|
47
|
+
undefined === obj ||
|
|
48
|
+
null === obj ||
|
|
49
|
+
typeof obj !== 'object' ||
|
|
50
|
+
(obj.constructor instanceof Function &&
|
|
51
|
+
obj.constructor.name !== 'Object') ||
|
|
52
|
+
Symbol.iterator in obj ||
|
|
53
|
+
Symbol.asyncIterator in obj
|
|
54
|
+
) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const prototype = Object.getPrototypeOf(obj);
|
|
59
|
+
|
|
60
|
+
return null === prototype || prototype === Object.prototype;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Returns true if the given object is Iterable
|
|
65
|
+
* @param obj - the object to check
|
|
66
|
+
*/
|
|
67
|
+
export function isIterable(obj: any): obj is Iterable<unknown> {
|
|
68
|
+
return obj !== null && typeof obj === 'object' && Symbol.iterator in obj;
|
|
69
|
+
}
|