@powerlines/plugin-i18next 0.1.119 → 0.1.120
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/index.cjs +9 -9
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +3 -3
- package/dist/types/plugin.d.mts +3 -3
- package/package.json +3 -3
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.20/node_modules/@stryke/type-checks/dist/get-object-tag.cjs +0 -15
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.20/node_modules/@stryke/type-checks/dist/get-object-tag.mjs +0 -14
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.20/node_modules/@stryke/type-checks/dist/is-empty.cjs +0 -20
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.20/node_modules/@stryke/type-checks/dist/is-empty.mjs +0 -20
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.20/node_modules/@stryke/type-checks/dist/is-non-null-object.cjs +0 -16
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.20/node_modules/@stryke/type-checks/dist/is-non-null-object.mjs +0 -16
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.20/node_modules/@stryke/type-checks/dist/is-null.cjs +0 -12
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.20/node_modules/@stryke/type-checks/dist/is-null.mjs +0 -11
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.20/node_modules/@stryke/type-checks/dist/is-object.cjs +0 -19
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.20/node_modules/@stryke/type-checks/dist/is-object.mjs +0 -19
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.20/node_modules/@stryke/type-checks/dist/is-plain-object.cjs +0 -63
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.20/node_modules/@stryke/type-checks/dist/is-plain-object.mjs +0 -63
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.20/node_modules/@stryke/type-checks/dist/is-set-object.cjs +0 -19
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.20/node_modules/@stryke/type-checks/dist/is-set-object.mjs +0 -19
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.20/node_modules/@stryke/type-checks/dist/is-set.cjs +0 -19
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.20/node_modules/@stryke/type-checks/dist/is-set.mjs +0 -19
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.20/node_modules/@stryke/type-checks/dist/is-string.cjs +0 -12
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.20/node_modules/@stryke/type-checks/dist/is-string.mjs +0 -11
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.20/node_modules/@stryke/type-checks/dist/is-undefined.cjs +0 -8
- package/dist/node_modules/.pnpm/@stryke_type-checks@0.5.20/node_modules/@stryke/type-checks/dist/is-undefined.mjs +0 -7
- /package/dist/{packages/powerlines → powerlines}/src/internal/helpers/hooks.d.mts +0 -0
- /package/dist/{packages/powerlines → powerlines}/src/types/api.d.mts +0 -0
- /package/dist/{packages/powerlines → powerlines}/src/types/build.d.mts +0 -0
- /package/dist/{packages/powerlines → powerlines}/src/types/commands.d.mts +0 -0
- /package/dist/{packages/powerlines → powerlines}/src/types/config.d.mts +0 -0
- /package/dist/{packages/powerlines → powerlines}/src/types/context.d.mts +0 -0
- /package/dist/{packages/powerlines → powerlines}/src/types/fs.d.mts +0 -0
- /package/dist/{packages/powerlines → powerlines}/src/types/hooks.d.mts +0 -0
- /package/dist/{packages/powerlines → powerlines}/src/types/plugin.d.mts +0 -0
- /package/dist/{packages/powerlines → powerlines}/src/types/resolved.d.mts +0 -0
- /package/dist/{packages/powerlines → powerlines}/src/types/tsconfig.d.mts +0 -0
- /package/dist/{packages/powerlines → powerlines}/src/types/unplugin.d.mts +0 -0
package/dist/index.cjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
2
|
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
3
|
-
const require_is_set = require('./node_modules/.pnpm/@stryke_type-checks@0.5.20/node_modules/@stryke/type-checks/dist/is-set.cjs');
|
|
4
|
-
const require_is_set_object = require('./node_modules/.pnpm/@stryke_type-checks@0.5.20/node_modules/@stryke/type-checks/dist/is-set-object.cjs');
|
|
5
|
-
const require_is_string = require('./node_modules/.pnpm/@stryke_type-checks@0.5.20/node_modules/@stryke/type-checks/dist/is-string.cjs');
|
|
6
3
|
const require_config_utils = require('./helpers/config-utils.cjs');
|
|
7
4
|
let __stryke_fs_list_files = require("@stryke/fs/list-files");
|
|
8
5
|
let __stryke_path_append = require("@stryke/path/append");
|
|
9
6
|
let __stryke_path_file_path_fns = require("@stryke/path/file-path-fns");
|
|
10
7
|
let __stryke_path_join = require("@stryke/path/join");
|
|
8
|
+
let __stryke_type_checks_is_set = require("@stryke/type-checks/is-set");
|
|
9
|
+
let __stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
10
|
+
let __stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
11
11
|
let defu = require("defu");
|
|
12
12
|
defu = require_rolldown_runtime.__toESM(defu);
|
|
13
13
|
let i18next_cli = require("i18next-cli");
|
|
@@ -51,7 +51,7 @@ const plugin = (options = {}) => {
|
|
|
51
51
|
locales: []
|
|
52
52
|
});
|
|
53
53
|
if (!i18next.locales || i18next.locales.length === 0) i18next.locales = [i18next.extract.primaryLanguage || "en"];
|
|
54
|
-
if (!
|
|
54
|
+
if (!(0, __stryke_type_checks_is_set.isSet)(i18next.types.indentation)) i18next.types.indentation = i18next.extract.indentation;
|
|
55
55
|
return { i18next };
|
|
56
56
|
},
|
|
57
57
|
async configResolved() {},
|
|
@@ -78,13 +78,13 @@ const plugin = (options = {}) => {
|
|
|
78
78
|
for (const file of await (0, __stryke_fs_list_files.listFiles)(require_config_utils.getOutputPath(this.config.i18next.extract.output, this.config.i18next.extract.primaryLanguage, "*"))) {
|
|
79
79
|
const namespace = (0, __stryke_path_file_path_fns.findFileName)(file, { withExtension: false });
|
|
80
80
|
const parsedContent = await this.resolver.import(file);
|
|
81
|
-
if (this.config.i18next.extract.mergeNamespaces &&
|
|
82
|
-
if (Object.keys(parsedContent).filter((k) =>
|
|
83
|
-
for (const nsName of Object.keys(parsedContent).filter((k) =>
|
|
81
|
+
if (this.config.i18next.extract.mergeNamespaces && (0, __stryke_type_checks_is_set_object.isSetObject)(parsedContent)) {
|
|
82
|
+
if (Object.keys(parsedContent).filter((k) => (0, __stryke_type_checks_is_set_object.isSetObject)(parsedContent[k])).length > 0) {
|
|
83
|
+
for (const nsName of Object.keys(parsedContent).filter((k) => (0, __stryke_type_checks_is_set_object.isSetObject)(parsedContent[k]))) resources.push({
|
|
84
84
|
name: nsName,
|
|
85
85
|
resources: parsedContent[nsName]
|
|
86
86
|
});
|
|
87
|
-
if (Object.keys(parsedContent).filter((k) => !
|
|
87
|
+
if (Object.keys(parsedContent).filter((k) => !(0, __stryke_type_checks_is_set_object.isSetObject)(parsedContent[k])).length > 0) this.warn(`The file ${file} contains top-level keys that are not objects (${Object.keys(parsedContent).filter((k) => !(0, __stryke_type_checks_is_set_object.isSetObject)(parsedContent[k])).join(", ")}). When 'mergeNamespaces' is enabled, top-level keys are treated as namespaces. These keys will be ignored.`);
|
|
88
88
|
continue;
|
|
89
89
|
}
|
|
90
90
|
}
|
|
@@ -112,7 +112,7 @@ ${(0, i18next_resources_for_ts.mergeResourcesAsInterface)(resources, {
|
|
|
112
112
|
*/
|
|
113
113
|
declare module 'i18next' {
|
|
114
114
|
interface CustomTypeOptions {
|
|
115
|
-
enableSelector: ${
|
|
115
|
+
enableSelector: ${(0, __stryke_type_checks_is_string.isString)(this.config.i18next.types.enableSelector) ? `"${this.config.i18next.types.enableSelector}"` : this.config.i18next.types.enableSelector};
|
|
116
116
|
defaultNS: ${this.config.i18next.extract.defaultNS === false ? "false" : `'${this.config.i18next.extract.defaultNS || "translation"}'`};
|
|
117
117
|
resources: Resources;
|
|
118
118
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Plugin } from "./
|
|
1
|
+
import { Plugin } from "./powerlines/src/types/plugin.mjs";
|
|
2
2
|
import { I18NextPluginContext, I18NextPluginOptions, I18NextPluginResolvedConfig, I18NextPluginUserConfig } from "./types/plugin.mjs";
|
|
3
3
|
import { Resource, ResourceContent } from "./types/i18n.mjs";
|
|
4
4
|
import "./types/index.mjs";
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { isSet } from "./node_modules/.pnpm/@stryke_type-checks@0.5.20/node_modules/@stryke/type-checks/dist/is-set.mjs";
|
|
2
|
-
import { isSetObject } from "./node_modules/.pnpm/@stryke_type-checks@0.5.20/node_modules/@stryke/type-checks/dist/is-set-object.mjs";
|
|
3
|
-
import { isString } from "./node_modules/.pnpm/@stryke_type-checks@0.5.20/node_modules/@stryke/type-checks/dist/is-string.mjs";
|
|
4
1
|
import { getOutputPath } from "./helpers/config-utils.mjs";
|
|
5
2
|
import { listFiles } from "@stryke/fs/list-files";
|
|
6
3
|
import { appendPath } from "@stryke/path/append";
|
|
7
4
|
import { findFileName } from "@stryke/path/file-path-fns";
|
|
8
5
|
import { joinPaths } from "@stryke/path/join";
|
|
6
|
+
import { isSet } from "@stryke/type-checks/is-set";
|
|
7
|
+
import { isSetObject } from "@stryke/type-checks/is-set-object";
|
|
8
|
+
import { isString } from "@stryke/type-checks/is-string";
|
|
9
9
|
import defu from "defu";
|
|
10
10
|
import { runExtractor } from "i18next-cli";
|
|
11
11
|
import { mergeResourcesAsInterface } from "i18next-resources-for-ts";
|
package/dist/types/plugin.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { UserConfig } from "../
|
|
2
|
-
import { ResolvedConfig } from "../
|
|
3
|
-
import { PluginContext } from "../
|
|
1
|
+
import { UserConfig } from "../powerlines/src/types/config.mjs";
|
|
2
|
+
import { ResolvedConfig } from "../powerlines/src/types/resolved.mjs";
|
|
3
|
+
import { PluginContext } from "../powerlines/src/types/context.mjs";
|
|
4
4
|
import { I18nextToolkitConfig } from "i18next-cli";
|
|
5
5
|
import { DeepPartial } from "@stryke/types/base";
|
|
6
6
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-i18next",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.120",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A Powerlines plugin to use i18next for internationalization.",
|
|
6
6
|
"repository": {
|
|
@@ -126,9 +126,9 @@
|
|
|
126
126
|
"powerlines": "^0.37.95"
|
|
127
127
|
},
|
|
128
128
|
"devDependencies": {
|
|
129
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
129
|
+
"@powerlines/plugin-plugin": "^0.12.174",
|
|
130
130
|
"@types/node": "^24.10.9"
|
|
131
131
|
},
|
|
132
132
|
"publishConfig": { "access": "public" },
|
|
133
|
-
"gitHead": "
|
|
133
|
+
"gitHead": "2852dab8ff7cad2d1aa4a44d7fd2479d62f65d47"
|
|
134
134
|
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.20/node_modules/@stryke/type-checks/dist/get-object-tag.mjs
|
|
3
|
-
/**
|
|
4
|
-
* Gets the `toStringTag` of `obj`.
|
|
5
|
-
*
|
|
6
|
-
* @param value - The obj to query.
|
|
7
|
-
* @returns Returns the `toStringTag`.
|
|
8
|
-
*/
|
|
9
|
-
const getObjectTag = (value) => {
|
|
10
|
-
if (value == null) return value === void 0 ? "[object Undefined]" : "[object Null]";
|
|
11
|
-
return Object.prototype.toString.call(value);
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
//#endregion
|
|
15
|
-
exports.getObjectTag = getObjectTag;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.20/node_modules/@stryke/type-checks/dist/get-object-tag.mjs
|
|
2
|
-
/**
|
|
3
|
-
* Gets the `toStringTag` of `obj`.
|
|
4
|
-
*
|
|
5
|
-
* @param value - The obj to query.
|
|
6
|
-
* @returns Returns the `toStringTag`.
|
|
7
|
-
*/
|
|
8
|
-
const getObjectTag = (value) => {
|
|
9
|
-
if (value == null) return value === void 0 ? "[object Undefined]" : "[object Null]";
|
|
10
|
-
return Object.prototype.toString.call(value);
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
//#endregion
|
|
14
|
-
export { getObjectTag };
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
const require_is_null = require('./is-null.cjs');
|
|
2
|
-
const require_is_undefined = require('./is-undefined.cjs');
|
|
3
|
-
|
|
4
|
-
//#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.20/node_modules/@stryke/type-checks/dist/is-empty.mjs
|
|
5
|
-
/**
|
|
6
|
-
* Check if the provided value's type is `null` or `undefined`
|
|
7
|
-
*
|
|
8
|
-
* @param value - The value to type check
|
|
9
|
-
* @returns An indicator specifying if the value provided is of type `null` or `undefined`
|
|
10
|
-
*/
|
|
11
|
-
const isEmpty = (value) => {
|
|
12
|
-
try {
|
|
13
|
-
return require_is_undefined.isUndefined(value) || require_is_null.isNull(value);
|
|
14
|
-
} catch {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
//#endregion
|
|
20
|
-
exports.isEmpty = isEmpty;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { isNull } from "./is-null.mjs";
|
|
2
|
-
import { isUndefined } from "./is-undefined.mjs";
|
|
3
|
-
|
|
4
|
-
//#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.20/node_modules/@stryke/type-checks/dist/is-empty.mjs
|
|
5
|
-
/**
|
|
6
|
-
* Check if the provided value's type is `null` or `undefined`
|
|
7
|
-
*
|
|
8
|
-
* @param value - The value to type check
|
|
9
|
-
* @returns An indicator specifying if the value provided is of type `null` or `undefined`
|
|
10
|
-
*/
|
|
11
|
-
const isEmpty = (value) => {
|
|
12
|
-
try {
|
|
13
|
-
return isUndefined(value) || isNull(value);
|
|
14
|
-
} catch {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
//#endregion
|
|
20
|
-
export { isEmpty };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const require_is_set = require('./is-set.cjs');
|
|
2
|
-
const require_is_object = require('./is-object.cjs');
|
|
3
|
-
|
|
4
|
-
//#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.20/node_modules/@stryke/type-checks/dist/is-non-null-object.mjs
|
|
5
|
-
/**
|
|
6
|
-
* Check if the provided value's type is `Object` and is not `null` or `undefined`
|
|
7
|
-
*
|
|
8
|
-
* @param value - The value to type check
|
|
9
|
-
* @returns An indicator specifying if the value provided is of type `Object` and is not `null` or `undefined`
|
|
10
|
-
*/
|
|
11
|
-
const isNonNullObject = (value) => {
|
|
12
|
-
return require_is_set.isSet(value) && require_is_object.isObject(value);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
//#endregion
|
|
16
|
-
exports.isNonNullObject = isNonNullObject;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { isSet } from "./is-set.mjs";
|
|
2
|
-
import { isObject } from "./is-object.mjs";
|
|
3
|
-
|
|
4
|
-
//#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.20/node_modules/@stryke/type-checks/dist/is-non-null-object.mjs
|
|
5
|
-
/**
|
|
6
|
-
* Check if the provided value's type is `Object` and is not `null` or `undefined`
|
|
7
|
-
*
|
|
8
|
-
* @param value - The value to type check
|
|
9
|
-
* @returns An indicator specifying if the value provided is of type `Object` and is not `null` or `undefined`
|
|
10
|
-
*/
|
|
11
|
-
const isNonNullObject = (value) => {
|
|
12
|
-
return isSet(value) && isObject(value);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
//#endregion
|
|
16
|
-
export { isNonNullObject };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.20/node_modules/@stryke/type-checks/dist/is-null.mjs
|
|
3
|
-
const isNull = (value) => {
|
|
4
|
-
try {
|
|
5
|
-
return value === null;
|
|
6
|
-
} catch {
|
|
7
|
-
return false;
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
//#endregion
|
|
12
|
-
exports.isNull = isNull;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const require_is_plain_object = require('./is-plain-object.cjs');
|
|
2
|
-
|
|
3
|
-
//#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.20/node_modules/@stryke/type-checks/dist/is-object.mjs
|
|
4
|
-
/**
|
|
5
|
-
* Check if the provided value's type is `Object`
|
|
6
|
-
*
|
|
7
|
-
* @param value - The value to type check
|
|
8
|
-
* @returns An indicator specifying if the value provided is of type `Object`
|
|
9
|
-
*/
|
|
10
|
-
const isObject = (value) => {
|
|
11
|
-
try {
|
|
12
|
-
return typeof value === "object" || Boolean(value) && value?.constructor === Object || require_is_plain_object.isPlainObject(value);
|
|
13
|
-
} catch {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
//#endregion
|
|
19
|
-
exports.isObject = isObject;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { isPlainObject } from "./is-plain-object.mjs";
|
|
2
|
-
|
|
3
|
-
//#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.20/node_modules/@stryke/type-checks/dist/is-object.mjs
|
|
4
|
-
/**
|
|
5
|
-
* Check if the provided value's type is `Object`
|
|
6
|
-
*
|
|
7
|
-
* @param value - The value to type check
|
|
8
|
-
* @returns An indicator specifying if the value provided is of type `Object`
|
|
9
|
-
*/
|
|
10
|
-
const isObject = (value) => {
|
|
11
|
-
try {
|
|
12
|
-
return typeof value === "object" || Boolean(value) && value?.constructor === Object || isPlainObject(value);
|
|
13
|
-
} catch {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
//#endregion
|
|
19
|
-
export { isObject };
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
const require_get_object_tag = require('./get-object-tag.cjs');
|
|
2
|
-
|
|
3
|
-
//#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.20/node_modules/@stryke/type-checks/dist/is-plain-object.mjs
|
|
4
|
-
/**
|
|
5
|
-
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
6
|
-
* and has a `typeof` result of "object".
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* isObjectLike({})
|
|
11
|
-
* // => true
|
|
12
|
-
*
|
|
13
|
-
* isObjectLike([1, 2, 3])
|
|
14
|
-
* // => true
|
|
15
|
-
*
|
|
16
|
-
* isObjectLike(Function)
|
|
17
|
-
* // => false
|
|
18
|
-
*
|
|
19
|
-
* isObjectLike(null)
|
|
20
|
-
* // => false
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* @param value - The value to check.
|
|
24
|
-
* @returns Returns `true` if `value` is object-like, else `false`.
|
|
25
|
-
*/
|
|
26
|
-
const isObjectLike = (obj) => {
|
|
27
|
-
return typeof obj === "object" && obj !== null;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Checks if `obj` is a plain object, that is, an object created by the `Object` constructor or one with a `[[Prototype]]` of `null`.
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* ```typescript
|
|
34
|
-
* function Foo() {
|
|
35
|
-
* this.a = 1
|
|
36
|
-
* }
|
|
37
|
-
*
|
|
38
|
-
* isPlainObject(new Foo)
|
|
39
|
-
* // => false
|
|
40
|
-
*
|
|
41
|
-
* isPlainObject([1, 2, 3])
|
|
42
|
-
* // => false
|
|
43
|
-
*
|
|
44
|
-
* isPlainObject({ 'x': 0, 'y': 0 })
|
|
45
|
-
* // => true
|
|
46
|
-
*
|
|
47
|
-
* isPlainObject(Object.create(null))
|
|
48
|
-
* // => true
|
|
49
|
-
* ```
|
|
50
|
-
*
|
|
51
|
-
* @param obj - The value to check.
|
|
52
|
-
* @returns Returns `true` if `obj` is a plain object, else `false`.
|
|
53
|
-
*/
|
|
54
|
-
const isPlainObject = (obj) => {
|
|
55
|
-
if (!isObjectLike(obj) || require_get_object_tag.getObjectTag(obj) !== "[object Object]") return false;
|
|
56
|
-
if (Object.getPrototypeOf(obj) === null) return true;
|
|
57
|
-
let proto = obj;
|
|
58
|
-
while (Object.getPrototypeOf(proto) !== null) proto = Object.getPrototypeOf(proto);
|
|
59
|
-
return Object.getPrototypeOf(obj) === proto;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
//#endregion
|
|
63
|
-
exports.isPlainObject = isPlainObject;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { getObjectTag } from "./get-object-tag.mjs";
|
|
2
|
-
|
|
3
|
-
//#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.20/node_modules/@stryke/type-checks/dist/is-plain-object.mjs
|
|
4
|
-
/**
|
|
5
|
-
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
6
|
-
* and has a `typeof` result of "object".
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* isObjectLike({})
|
|
11
|
-
* // => true
|
|
12
|
-
*
|
|
13
|
-
* isObjectLike([1, 2, 3])
|
|
14
|
-
* // => true
|
|
15
|
-
*
|
|
16
|
-
* isObjectLike(Function)
|
|
17
|
-
* // => false
|
|
18
|
-
*
|
|
19
|
-
* isObjectLike(null)
|
|
20
|
-
* // => false
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* @param value - The value to check.
|
|
24
|
-
* @returns Returns `true` if `value` is object-like, else `false`.
|
|
25
|
-
*/
|
|
26
|
-
const isObjectLike = (obj) => {
|
|
27
|
-
return typeof obj === "object" && obj !== null;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Checks if `obj` is a plain object, that is, an object created by the `Object` constructor or one with a `[[Prototype]]` of `null`.
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* ```typescript
|
|
34
|
-
* function Foo() {
|
|
35
|
-
* this.a = 1
|
|
36
|
-
* }
|
|
37
|
-
*
|
|
38
|
-
* isPlainObject(new Foo)
|
|
39
|
-
* // => false
|
|
40
|
-
*
|
|
41
|
-
* isPlainObject([1, 2, 3])
|
|
42
|
-
* // => false
|
|
43
|
-
*
|
|
44
|
-
* isPlainObject({ 'x': 0, 'y': 0 })
|
|
45
|
-
* // => true
|
|
46
|
-
*
|
|
47
|
-
* isPlainObject(Object.create(null))
|
|
48
|
-
* // => true
|
|
49
|
-
* ```
|
|
50
|
-
*
|
|
51
|
-
* @param obj - The value to check.
|
|
52
|
-
* @returns Returns `true` if `obj` is a plain object, else `false`.
|
|
53
|
-
*/
|
|
54
|
-
const isPlainObject = (obj) => {
|
|
55
|
-
if (!isObjectLike(obj) || getObjectTag(obj) !== "[object Object]") return false;
|
|
56
|
-
if (Object.getPrototypeOf(obj) === null) return true;
|
|
57
|
-
let proto = obj;
|
|
58
|
-
while (Object.getPrototypeOf(proto) !== null) proto = Object.getPrototypeOf(proto);
|
|
59
|
-
return Object.getPrototypeOf(obj) === proto;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
//#endregion
|
|
63
|
-
export { isPlainObject };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const require_is_non_null_object = require('./is-non-null-object.cjs');
|
|
2
|
-
|
|
3
|
-
//#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.20/node_modules/@stryke/type-checks/dist/is-set-object.mjs
|
|
4
|
-
/**
|
|
5
|
-
* Check if the provided value's type is an object with some fields set
|
|
6
|
-
*
|
|
7
|
-
* @param value - The value to type check
|
|
8
|
-
* @returns An indicator specifying if the value provided is an object with some fields se
|
|
9
|
-
*/
|
|
10
|
-
const isSetObject = (value) => {
|
|
11
|
-
try {
|
|
12
|
-
return require_is_non_null_object.isNonNullObject(value) && Object.keys(value).length > 0;
|
|
13
|
-
} catch {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
//#endregion
|
|
19
|
-
exports.isSetObject = isSetObject;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { isNonNullObject } from "./is-non-null-object.mjs";
|
|
2
|
-
|
|
3
|
-
//#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.20/node_modules/@stryke/type-checks/dist/is-set-object.mjs
|
|
4
|
-
/**
|
|
5
|
-
* Check if the provided value's type is an object with some fields set
|
|
6
|
-
*
|
|
7
|
-
* @param value - The value to type check
|
|
8
|
-
* @returns An indicator specifying if the value provided is an object with some fields se
|
|
9
|
-
*/
|
|
10
|
-
const isSetObject = (value) => {
|
|
11
|
-
try {
|
|
12
|
-
return isNonNullObject(value) && Object.keys(value).length > 0;
|
|
13
|
-
} catch {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
//#endregion
|
|
19
|
-
export { isSetObject };
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const require_is_empty = require('./is-empty.cjs');
|
|
2
|
-
|
|
3
|
-
//#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.20/node_modules/@stryke/type-checks/dist/is-set.mjs
|
|
4
|
-
/**
|
|
5
|
-
* The inverse of the `isEmpty` function
|
|
6
|
-
*
|
|
7
|
-
* @param value - The value to type check
|
|
8
|
-
* @returns An indicator specifying if the value provided is **NOT** of type `null` or `undefined`
|
|
9
|
-
*/
|
|
10
|
-
const isSet = (value) => {
|
|
11
|
-
try {
|
|
12
|
-
return !require_is_empty.isEmpty(value);
|
|
13
|
-
} catch {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
//#endregion
|
|
19
|
-
exports.isSet = isSet;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { isEmpty } from "./is-empty.mjs";
|
|
2
|
-
|
|
3
|
-
//#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.20/node_modules/@stryke/type-checks/dist/is-set.mjs
|
|
4
|
-
/**
|
|
5
|
-
* The inverse of the `isEmpty` function
|
|
6
|
-
*
|
|
7
|
-
* @param value - The value to type check
|
|
8
|
-
* @returns An indicator specifying if the value provided is **NOT** of type `null` or `undefined`
|
|
9
|
-
*/
|
|
10
|
-
const isSet = (value) => {
|
|
11
|
-
try {
|
|
12
|
-
return !isEmpty(value);
|
|
13
|
-
} catch {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
//#endregion
|
|
19
|
-
export { isSet };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.20/node_modules/@stryke/type-checks/dist/is-string.mjs
|
|
3
|
-
const isString = (value) => {
|
|
4
|
-
try {
|
|
5
|
-
return typeof value === "string";
|
|
6
|
-
} catch {
|
|
7
|
-
return false;
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
//#endregion
|
|
12
|
-
exports.isString = isString;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/@stryke+type-checks@0.5.20/node_modules/@stryke/type-checks/dist/is-string.mjs
|
|
2
|
-
const isString = (value) => {
|
|
3
|
-
try {
|
|
4
|
-
return typeof value === "string";
|
|
5
|
-
} catch {
|
|
6
|
-
return false;
|
|
7
|
-
}
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
//#endregion
|
|
11
|
-
export { isString };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|