@rimbu/base 2.0.0 → 2.0.1
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/dist/cjs/arr.cjs +202 -229
- package/dist/cjs/arr.cjs.map +1 -0
- package/dist/cjs/entry.cjs +9 -32
- package/dist/cjs/entry.cjs.map +1 -0
- package/dist/cjs/index.cjs +9 -320
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.cts +5 -0
- package/dist/cjs/internal.cjs +4 -31
- package/dist/cjs/internal.cjs.map +1 -0
- package/dist/cjs/internal.d.cts +1 -0
- package/dist/cjs/plain-object.cjs +22 -32
- package/dist/cjs/plain-object.cjs.map +1 -0
- package/dist/cjs/rimbu-error.cjs +45 -66
- package/dist/cjs/rimbu-error.cjs.map +1 -0
- package/dist/cjs/token.cjs +4 -29
- package/dist/cjs/token.cjs.map +1 -0
- package/dist/esm/arr.d.mts +33 -0
- package/dist/esm/entry.d.mts +2 -0
- package/dist/esm/plain-object.d.mts +62 -0
- package/dist/esm/rimbu-error.d.mts +16 -0
- package/dist/esm/token.d.mts +2 -0
- package/package.json +19 -13
- /package/dist/{types/arr.d.mts → cjs/arr.d.cts} +0 -0
- /package/dist/{types/entry.d.mts → cjs/entry.d.cts} +0 -0
- /package/dist/{types/plain-object.d.mts → cjs/plain-object.d.cts} +0 -0
- /package/dist/{types/rimbu-error.d.mts → cjs/rimbu-error.d.cts} +0 -0
- /package/dist/{types/token.d.mts → cjs/token.d.cts} +0 -0
- /package/dist/{types → esm}/index.d.mts +0 -0
- /package/dist/{types → esm}/internal.d.mts +0 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Matches any type of function
|
|
3
|
+
*/
|
|
4
|
+
export type AnyFunc = (...args: any[]) => any;
|
|
5
|
+
/**
|
|
6
|
+
* Gives true if the given type T is a function, false otherwise.
|
|
7
|
+
* @typeparam T - the input type
|
|
8
|
+
*/
|
|
9
|
+
export type IsAnyFunc<T> = AnyFunc extends T ? true : false;
|
|
10
|
+
/**
|
|
11
|
+
* A predicate type for any record that resolves to true if any of the record
|
|
12
|
+
* properties is a function, false otherwise.
|
|
13
|
+
* This is useful to have a coarse discrimination between pure data objects and class instances.
|
|
14
|
+
* @typeparam T - the input type
|
|
15
|
+
*/
|
|
16
|
+
export type IsObjWithoutFunctions<T> = AnyFunc extends T[keyof T] ? false : true;
|
|
17
|
+
/**
|
|
18
|
+
* A predicate type that resolves to true if the given type satisfies:
|
|
19
|
+
* - it is an object type (not a primitive)
|
|
20
|
+
* - it is not a function
|
|
21
|
+
* - it is not iterable
|
|
22
|
+
* - it does not have any properties that are functions
|
|
23
|
+
* Otherwise, it resolves to false
|
|
24
|
+
* @typeparam T - the input type
|
|
25
|
+
*/
|
|
26
|
+
export type IsPlainObj<T> = T extends null | undefined | number | string | boolean | bigint | symbol | AnyFunc | Iterable<any> | AsyncIterable<any> ? false : IsObjWithoutFunctions<T>;
|
|
27
|
+
/**
|
|
28
|
+
* Utility type that will only accept objects that are considered 'plain objects' according
|
|
29
|
+
* to the `IsPlainObj` predicate type.
|
|
30
|
+
* @typeparam T - the value type to test
|
|
31
|
+
*/
|
|
32
|
+
export type PlainObj<T> = IsPlainObj<T> extends true ? T : never;
|
|
33
|
+
/**
|
|
34
|
+
* Utility type that will only return true if the input type T is equal to `any`.
|
|
35
|
+
* @typeparam T - the value type to test
|
|
36
|
+
*/
|
|
37
|
+
export type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
38
|
+
/**
|
|
39
|
+
* Utility type that will only return true if the input type T is a (readonly) array.
|
|
40
|
+
* @typeparm T - the value type to test
|
|
41
|
+
*/
|
|
42
|
+
export type IsArray<T> = T extends readonly any[] ? true : false;
|
|
43
|
+
/**
|
|
44
|
+
* Utility type to exclude any types that are iterable. Useful in cases where
|
|
45
|
+
* plain objects are required as inputs but not arrays.
|
|
46
|
+
*/
|
|
47
|
+
export type NotIterable = {
|
|
48
|
+
[Symbol.iterator]?: never;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Companion function to the `IsRecord<T>` type that checks whether the given object is a pure
|
|
52
|
+
* data object.
|
|
53
|
+
* @param obj - the object to check
|
|
54
|
+
* @returns true if the given object is a pure data object
|
|
55
|
+
* @note does not check whether a record's properties are not functions
|
|
56
|
+
*/
|
|
57
|
+
export declare function isPlainObj(obj: any): obj is object;
|
|
58
|
+
/**
|
|
59
|
+
* Returns true if the given object is Iterable
|
|
60
|
+
* @param obj - the object to check
|
|
61
|
+
*/
|
|
62
|
+
export declare function isIterable(obj: any): obj is Iterable<unknown>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ErrBase } from '@rimbu/common';
|
|
2
|
+
export declare class EmptyCollectionAssumedNonEmptyError extends ErrBase.CustomError {
|
|
3
|
+
constructor();
|
|
4
|
+
}
|
|
5
|
+
export declare class ModifiedBuilderWhileLoopingOverItError extends ErrBase.CustomError {
|
|
6
|
+
constructor();
|
|
7
|
+
}
|
|
8
|
+
export declare class InvalidStateError extends ErrBase.CustomError {
|
|
9
|
+
constructor();
|
|
10
|
+
}
|
|
11
|
+
export declare class InvalidUsageError extends ErrBase.CustomError {
|
|
12
|
+
}
|
|
13
|
+
export declare function throwEmptyCollectionAssumedNonEmptyError(): never;
|
|
14
|
+
export declare function throwModifiedBuilderWhileLoopingOverItError(): never;
|
|
15
|
+
export declare function throwInvalidStateError(): never;
|
|
16
|
+
export declare function throwInvalidUsageError(msg: string): never;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rimbu/base",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Utilities to implement Rimbu collections",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"array",
|
|
@@ -29,14 +29,18 @@
|
|
|
29
29
|
"type": "module",
|
|
30
30
|
"main": "./dist/cjs/index.cjs",
|
|
31
31
|
"module": "./dist/esm/index.mjs",
|
|
32
|
-
"types": "./dist/
|
|
32
|
+
"types": "./dist/cjs/index.d.cts",
|
|
33
33
|
"exports": {
|
|
34
34
|
".": {
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"
|
|
35
|
+
"import": {
|
|
36
|
+
"types": "./dist/esm/index.d.mts",
|
|
37
|
+
"default": "./dist/esm/index.mjs"
|
|
38
|
+
},
|
|
39
|
+
"require": {
|
|
40
|
+
"types": "./dist/cjs/index.d.cts",
|
|
41
|
+
"default": "./dist/cjs/index.cjs"
|
|
42
|
+
},
|
|
43
|
+
"bun": "./dist/bun/main/index.mts"
|
|
40
44
|
}
|
|
41
45
|
},
|
|
42
46
|
"files": [
|
|
@@ -46,15 +50,17 @@
|
|
|
46
50
|
"scripts": {
|
|
47
51
|
"build": "yarn clean && yarn bundle",
|
|
48
52
|
"build:deno": "yarn bundle:deno-prepare && yarn bundle:deno-convert && yarn bundle:deno-move && yarn bundle:deno-clean",
|
|
49
|
-
"bundle": "yarn bundle:cjs && yarn bundle:esm && yarn bundle:
|
|
50
|
-
"bundle:bun": "node ../../config/bunnify.mjs",
|
|
51
|
-
"bundle:cjs": "
|
|
53
|
+
"bundle": "yarn bundle:cjs && yarn bundle:esm && yarn bundle:bun",
|
|
54
|
+
"bundle:bun": "node ../../config/bunnify.mjs -mode bun",
|
|
55
|
+
"bundle:cjs": "yarn bundle:cjs-prepare && yarn bundle:cjs-build && yarn bundle:cjs-clean",
|
|
56
|
+
"bundle:cjs-prepare": "node ../../config/bunnify.mjs -mode cjs",
|
|
57
|
+
"bundle:cjs-build": "tsc -p tsconfig.cjs.json",
|
|
58
|
+
"bundle:cjs-clean": "rimraf _cjs_prepare",
|
|
52
59
|
"bundle:deno-prepare": "node ../../config/prepare-denoify.mjs",
|
|
53
60
|
"bundle:deno-convert": "denoify --src _deno_prepare/src",
|
|
54
61
|
"bundle:deno-move": "rimraf ../../deno_dist/base && mv deno_dist ../../deno_dist/base",
|
|
55
62
|
"bundle:deno-clean": "rimraf _deno_prepare",
|
|
56
63
|
"bundle:esm": "tsc --p tsconfig.esm.json",
|
|
57
|
-
"bundle:types": "tsc --p tsconfig.types.json",
|
|
58
64
|
"clean": "rimraf dist",
|
|
59
65
|
"format": "yarn format:base --write",
|
|
60
66
|
"format:base": "prettier \"{!CHANGELOG.md}|**/**/*.{ts,tsx,js,mts,mjs,json,md}\"",
|
|
@@ -67,10 +73,10 @@
|
|
|
67
73
|
"typecheck": "tsc"
|
|
68
74
|
},
|
|
69
75
|
"dependencies": {
|
|
70
|
-
"@rimbu/common": "^2.0.
|
|
76
|
+
"@rimbu/common": "^2.0.1"
|
|
71
77
|
},
|
|
72
78
|
"publishConfig": {
|
|
73
79
|
"access": "public"
|
|
74
80
|
},
|
|
75
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "b7ed656d2c55d1a715d6a3f52e364e68cb98c759"
|
|
76
82
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|