Skip to content

Commit 4617b4d

Browse files
committed
chore(sdk): move libraries from v2
1 parent 4f11835 commit 4617b4d

File tree

6 files changed

+64
-0
lines changed

6 files changed

+64
-0
lines changed

packages/sdk/package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@
3434
"types": "./dist/schema.d.cts",
3535
"default": "./dist/schema.cjs"
3636
}
37+
},
38+
"./local-helpers": {
39+
"import": {
40+
"types": "./dist/local-helpers.d.ts",
41+
"default": "./dist/local-helpers.js"
42+
},
43+
"require": {
44+
"types": "./dist/local-helpers.d.cts",
45+
"default": "./dist/local-helpers.cjs"
46+
}
3747
}
3848
},
3949
"dependencies": {
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export * from './is-plain-object';
2+
export * from './lower-case-first';
3+
export * from './upper-case-first';
4+
export * from './tiny-invariant';
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
function isObject(o: unknown) {
2+
return Object.prototype.toString.call(o) === '[object Object]';
3+
}
4+
5+
export function isPlainObject(o: unknown) {
6+
if (isObject(o) === false) return false;
7+
8+
// If has modified constructor
9+
const ctor = (o as { constructor: unknown }).constructor;
10+
if (ctor === undefined) return true;
11+
12+
// If has modified prototype
13+
const prot = (ctor as { prototype: unknown }).prototype;
14+
if (isObject(prot) === false) return false;
15+
16+
// If constructor does not have an Object-specific method
17+
if (Object.prototype.hasOwnProperty.call(prot, 'isPrototypeOf') === false) {
18+
return false;
19+
}
20+
21+
// Most likely a plain Object
22+
return true;
23+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export function lowerCaseFirst(input: string) {
2+
return input.charAt(0).toLowerCase() + input.slice(1);
3+
}
4+
5+
export { lowerCaseFirst as uncapitalize };
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const isProduction = process.env['NODE_ENV'] === 'production';
2+
const prefix = 'Invariant failed';
3+
4+
export function invariant(
5+
condition: unknown,
6+
message?: string,
7+
): asserts condition {
8+
if (condition) {
9+
return;
10+
}
11+
12+
if (isProduction) {
13+
throw new Error(prefix);
14+
}
15+
16+
throw new Error(message ? `${prefix}: ${message}` : prefix);
17+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export function upperCaseFirst(input: string) {
2+
return input.charAt(0).toUpperCase() + input.slice(1);
3+
}
4+
5+
export { upperCaseFirst as capitalize };

0 commit comments

Comments
 (0)