@socketsecurity/lib 6.0.4 → 6.0.6
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/CHANGELOG.md +24 -0
- package/dist/ai/discover.js +3 -2
- package/dist/ai/spawn.js +8 -5
- package/dist/ai/worktree.js +11 -6
- package/dist/ansi/strip.js +2 -2
- package/dist/archives/_internal.js +4 -4
- package/dist/archives/zip.js +1 -1
- package/dist/arrays/_internal.js +2 -2
- package/dist/arrays/chunk.js +1 -1
- package/dist/arrays/join.js +2 -2
- package/dist/arrays/unique.js +1 -1
- package/dist/bin/acorn-bindgen.cjs +769 -0
- package/dist/bin/acorn.wasm +0 -0
- package/dist/bin/check-primordials.js +3 -2
- package/dist/bin/check.js +3 -2
- package/dist/bin/exec.js +1 -1
- package/dist/bin/prim.cjs +39064 -0
- package/dist/bin/resolve.js +1 -1
- package/dist/colors/socket-palette.js +2 -2
- package/dist/compression/_internal.js +3 -2
- package/dist/compression/brotli.js +5 -12
- package/dist/compression/gzip.js +5 -13
- package/dist/constants/agents.js +4 -4
- package/dist/constants/packages.js +6 -6
- package/dist/constants/socket.js +1 -1
- package/dist/crypto/hash.js +2 -2
- package/dist/debug/_internal.js +2 -2
- package/dist/debug/caller-info.js +1 -1
- package/dist/debug/namespace.js +5 -5
- package/dist/debug/output.js +3 -3
- package/dist/dlx/binary-download.js +3 -2
- package/dist/eco/npm/npm/flags.js +5 -5
- package/dist/eco/npm/pnpm/flags.js +3 -3
- package/dist/env/boolean.js +1 -1
- package/dist/env/ci.js +1 -1
- package/dist/env/debug.js +1 -1
- package/dist/env/github.js +8 -8
- package/dist/env/home.js +1 -1
- package/dist/env/locale.js +3 -3
- package/dist/env/node-auth-token.js +1 -1
- package/dist/env/node-env.js +1 -1
- package/dist/env/npm.js +5 -5
- package/dist/env/number.js +1 -1
- package/dist/env/package-manager.js +3 -3
- package/dist/env/path.js +1 -1
- package/dist/env/pre-commit.js +1 -1
- package/dist/env/rewire.js +2 -2
- package/dist/env/shell.js +1 -1
- package/dist/env/socket-cli.js +13 -13
- package/dist/env/socket.js +33 -32
- package/dist/env/string.js +1 -1
- package/dist/env/temp-dir.js +3 -3
- package/dist/env/term.js +1 -1
- package/dist/env/test.js +3 -3
- package/dist/env/windows.js +4 -4
- package/dist/env/xdg.js +3 -3
- package/dist/events/exit/_internal.js +5 -5
- package/dist/events/exit/handler.js +1 -1
- package/dist/events/exit/intercept.js +2 -2
- package/dist/events/exit/lifecycle.js +3 -3
- package/dist/events/exit/signals.js +1 -1
- package/dist/external/@sinclair/typebox/value.js +5 -1
- package/dist/external/@sinclair/typebox.js +5 -1
- package/dist/external/@socketregistry/packageurl-js.js +27 -0
- package/dist/external-tools/bazel/resolve.js +2 -1
- package/dist/external-tools/cdxgen/resolve.js +2 -1
- package/dist/external-tools/from-pip-venv.d.ts +73 -0
- package/dist/external-tools/from-pip-venv.js +98 -0
- package/dist/external-tools/janus/asset-names.js +1 -1
- package/dist/external-tools/janus/from-download.js +3 -5
- package/dist/external-tools/janus/resolve.js +2 -1
- package/dist/external-tools/jre/from-download.js +2 -1
- package/dist/external-tools/jre/resolve.js +2 -1
- package/dist/external-tools/manifest.js +7 -5
- package/dist/external-tools/opengrep/resolve.js +2 -1
- package/dist/external-tools/sbt/resolve.js +2 -1
- package/dist/external-tools/skillspector/from-dlx.d.ts +24 -0
- package/dist/external-tools/skillspector/from-dlx.js +41 -0
- package/dist/external-tools/skillspector/from-path.d.ts +8 -0
- package/dist/external-tools/skillspector/from-path.js +32 -0
- package/dist/external-tools/skillspector/from-vfs.d.ts +8 -0
- package/dist/external-tools/skillspector/from-vfs.js +27 -0
- package/dist/external-tools/skillspector/resolve.d.ts +34 -0
- package/dist/external-tools/skillspector/resolve.js +53 -0
- package/dist/external-tools/skillspector/types.d.ts +24 -0
- package/dist/external-tools/skillspector/types.js +2 -0
- package/dist/external-tools/synp/resolve.js +2 -1
- package/dist/external-tools/trivy/resolve.js +2 -1
- package/dist/external-tools/trufflehog/resolve.js +2 -1
- package/dist/external-tools/uv/resolve.js +2 -1
- package/dist/fs/access.js +4 -4
- package/dist/fs/encoding.js +2 -2
- package/dist/fs/find-up.js +2 -2
- package/dist/fs/inspect.js +6 -6
- package/dist/fs/read-dir.js +3 -3
- package/dist/fs/read-file.js +6 -6
- package/dist/fs/read-json.js +2 -2
- package/dist/fs/safe.js +2 -2
- package/dist/fs/unique.js +1 -1
- package/dist/fs/validate.js +1 -1
- package/dist/fs/write-json.js +1 -1
- package/dist/git/_internal.js +2 -1
- package/dist/globs/_internal.js +4 -4
- package/dist/globs/match.js +4 -3
- package/dist/globs/matcher.js +3 -3
- package/dist/globs/stream.js +1 -1
- package/dist/http-request/browser.js +17 -11
- package/dist/http-request/download.js +1 -1
- package/dist/http-request/headers.d.ts +32 -3
- package/dist/http-request/headers.js +42 -13
- package/dist/http-request/request-attempt.js +1 -0
- package/dist/http-request/request-types.d.ts +5 -0
- package/dist/http-request/request.js +32 -15
- package/dist/http-request/response-reader.d.ts +12 -1
- package/dist/http-request/response-reader.js +22 -2
- package/dist/http-request/user-agent.js +1 -1
- package/dist/json/edit.js +1 -1
- package/dist/json/parse.js +4 -4
- package/dist/logger/colors.js +2 -2
- package/dist/logger/console.js +1 -1
- package/dist/logger/node.js +0 -1
- package/dist/logger/symbols.js +1 -1
- package/dist/node/async-hooks.js +2 -2
- package/dist/node/child-process.js +2 -2
- package/dist/node/crypto.js +2 -2
- package/dist/node/events.js +2 -2
- package/dist/node/fs-promises.js +2 -2
- package/dist/node/fs.js +2 -2
- package/dist/node/http.js +2 -2
- package/dist/node/https.js +2 -2
- package/dist/node/module.js +3 -3
- package/dist/node/os.js +2 -2
- package/dist/node/path.js +2 -2
- package/dist/node/timers-promises.js +2 -2
- package/dist/node/url.js +2 -2
- package/dist/node/util.js +2 -2
- package/dist/objects/getters.js +2 -2
- package/dist/objects/inspect.js +3 -3
- package/dist/objects/mutate.js +1 -1
- package/dist/objects/predicates.js +4 -4
- package/dist/objects/sort.js +4 -4
- package/dist/packages/edit-class.js +1 -1
- package/dist/packages/edit.js +2 -2
- package/dist/packages/exports.js +6 -6
- package/dist/packages/licenses.js +8 -8
- package/dist/packages/manifest.js +3 -3
- package/dist/packages/normalize.js +4 -4
- package/dist/packages/operations.js +11 -11
- package/dist/packages/provenance.d.ts +6 -0
- package/dist/packages/provenance.js +12 -3
- package/dist/packages/specs.js +5 -5
- package/dist/packages/validation.js +3 -3
- package/dist/paths/_internal.js +3 -3
- package/dist/paths/conversion.js +4 -4
- package/dist/paths/normalize.js +3 -1
- package/dist/paths/packages.js +3 -3
- package/dist/paths/predicates.js +7 -7
- package/dist/paths/resolve.js +3 -3
- package/dist/process/spawn/_internal.js +3 -3
- package/dist/process/spawn/errors.js +2 -2
- package/dist/process/spawn/stdio.js +1 -1
- package/dist/promises/_internal.js +1 -1
- package/dist/promises/iterate.js +5 -5
- package/dist/promises/options.js +3 -3
- package/dist/promises/retry.js +1 -1
- package/dist/secrets/_internal.js +3 -2
- package/dist/secrets/keychain.js +5 -4
- package/dist/secrets/linux.js +6 -4
- package/dist/secrets/macos.js +5 -3
- package/dist/secrets/rc.js +9 -6
- package/dist/secrets/windows.js +7 -4
- package/dist/shell/parse.d.ts +108 -1
- package/dist/shell/parse.js +168 -2
- package/dist/smol/detect.js +1 -1
- package/dist/smol/http.js +1 -1
- package/dist/smol/https.js +1 -1
- package/dist/smol/manifest.js +1 -1
- package/dist/smol/path.js +1 -1
- package/dist/smol/primordial.js +1 -1
- package/dist/smol/purl.js +1 -1
- package/dist/smol/versions.js +1 -1
- package/dist/smol/vfs.js +1 -1
- package/dist/sorts/_internal.js +4 -4
- package/dist/sorts/natural.js +3 -3
- package/dist/sorts/semver.js +1 -1
- package/dist/sorts/strings.js +1 -1
- package/dist/spinner/default.js +1 -1
- package/dist/spinner/spinner.js +1 -1
- package/dist/ssri/convert.js +2 -2
- package/dist/ssri/parse.js +1 -1
- package/dist/ssri/validate.js +2 -2
- package/dist/stdio/prompts.js +1 -1
- package/dist/streams/parallel.js +2 -2
- package/dist/streams/transform.js +1 -1
- package/dist/strings/format.js +4 -4
- package/dist/strings/predicates.js +2 -2
- package/dist/strings/search.js +1 -1
- package/dist/strings/transform.js +3 -3
- package/dist/strings/width.js +3 -3
- package/dist/temporal/instant.js +4 -2
- package/dist/temporal/slots.js +3 -2
- package/dist/themes/context.js +2 -2
- package/dist/url/parse.js +2 -2
- package/dist/url/predicates.js +1 -1
- package/dist/url/search-params.js +6 -6
- package/dist/words/article.js +1 -1
- package/dist/words/capitalize.js +1 -1
- package/dist/words/pluralize.d.ts +24 -2
- package/dist/words/pluralize.js +37 -2
- package/dist/words/types.d.ts +25 -2
- package/package.json +45 -5
|
@@ -31,7 +31,7 @@ const require_primordials_string = require('../primordials/string.js');
|
|
|
31
31
|
*
|
|
32
32
|
* @returns The string without BOM
|
|
33
33
|
*/
|
|
34
|
-
|
|
34
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
35
35
|
function stripBom(str) {
|
|
36
36
|
return str.length > 0 && require_primordials_string.StringPrototypeCharCodeAt(str, 0) === 65279 ? require_primordials_string.StringPrototypeSlice(str, 1) : str;
|
|
37
37
|
}
|
|
@@ -60,7 +60,7 @@ function stripBom(str) {
|
|
|
60
60
|
*
|
|
61
61
|
* @returns The kebab-case string
|
|
62
62
|
*/
|
|
63
|
-
|
|
63
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
64
64
|
function toKebabCase(str) {
|
|
65
65
|
if (!str.length) return str;
|
|
66
66
|
return require_primordials_string.StringPrototypeReplace(str, /([a-z]+[0-9]*)([A-Z])/g, "$1-$2").replace(/_/g, "-").toLowerCase();
|
|
@@ -90,7 +90,7 @@ function toKebabCase(str) {
|
|
|
90
90
|
*
|
|
91
91
|
* @returns The string with leading and trailing newlines removed
|
|
92
92
|
*/
|
|
93
|
-
|
|
93
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
94
94
|
function trimNewlines(str) {
|
|
95
95
|
const { length } = str;
|
|
96
96
|
if (length === 0) return str;
|
package/dist/strings/width.js
CHANGED
|
@@ -21,9 +21,9 @@ const require_ansi_strip = require('../ansi/strip.js');
|
|
|
21
21
|
* details and Unicode Standard Annex #11 references.
|
|
22
22
|
*/
|
|
23
23
|
let _eastAsianWidth;
|
|
24
|
-
|
|
24
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
25
25
|
function getEastAsianWidth() {
|
|
26
|
-
if (_eastAsianWidth === void 0) _eastAsianWidth = require("../external/get-east-asian-width").eastAsianWidth;
|
|
26
|
+
if (_eastAsianWidth === void 0) _eastAsianWidth = (/* @__PURE__ */ require("../external/get-east-asian-width")).eastAsianWidth;
|
|
27
27
|
return _eastAsianWidth;
|
|
28
28
|
}
|
|
29
29
|
const segmenter = new Intl.Segmenter();
|
|
@@ -65,7 +65,7 @@ try {
|
|
|
65
65
|
*
|
|
66
66
|
* @returns The visual width in terminal columns
|
|
67
67
|
*/
|
|
68
|
-
|
|
68
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
69
69
|
function stringWidth(text) {
|
|
70
70
|
if (typeof text !== "string" || !text.length) return 0;
|
|
71
71
|
/* c8 ignore next */
|
package/dist/temporal/instant.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
/* Socket Lib - Built with rolldown */
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
const require_primordials_error = require('../primordials/error.js');
|
|
5
|
+
const require_primordials_object = require('../primordials/object.js');
|
|
6
|
+
const require_primordials_json = require('../primordials/json.js');
|
|
5
7
|
const require_primordials_globals = require('../primordials/globals.js');
|
|
6
8
|
const require_temporal_slots = require('./slots.js');
|
|
7
9
|
|
|
@@ -58,7 +60,7 @@ function epochNanosecondsImpl() {
|
|
|
58
60
|
if (!require_temporal_slots.hasInstantSlot(instant)) throw new require_primordials_error.TypeErrorCtor(`Temporal.Instant.prototype.epochNanoseconds: receiver lacks [[InitializedTemporalInstant]] internal slot; saw ${describe(instant)}. Call on a Temporal.Instant instance constructed via 'new Temporal.Instant(…)'.`);
|
|
59
61
|
return require_temporal_slots.getInstantNanoseconds(instant);
|
|
60
62
|
}
|
|
61
|
-
|
|
63
|
+
require_primordials_object.ObjectDefineProperty(Instant.prototype, "epochNanoseconds", {
|
|
62
64
|
get: epochNanosecondsImpl,
|
|
63
65
|
configurable: true
|
|
64
66
|
});
|
|
@@ -72,7 +74,7 @@ function describe(value) {
|
|
|
72
74
|
const ctor = value.constructor;
|
|
73
75
|
return ctor && ctor.name ? `<${ctor.name}>` : "<object>";
|
|
74
76
|
}
|
|
75
|
-
return typeof value === "string" ?
|
|
77
|
+
return typeof value === "string" ? require_primordials_json.JSONStringify(value) : String(value);
|
|
76
78
|
}
|
|
77
79
|
|
|
78
80
|
//#endregion
|
package/dist/temporal/slots.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/* Socket Lib - Built with rolldown */
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
|
+
const require_primordials_map_set = require('../primordials/map-set.js');
|
|
4
5
|
|
|
5
6
|
//#region src/temporal/slots.ts
|
|
6
7
|
/**
|
|
@@ -19,8 +20,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
19
20
|
* `[[InitializedTemporalInstant]]` and `RequireInternalSlot`. Reference impl:
|
|
20
21
|
* js-temporal/temporal-polyfill `lib/slots.ts` (pinned commit in README.md).
|
|
21
22
|
*/
|
|
22
|
-
const _initializedInstant =
|
|
23
|
-
const _instantNanoseconds =
|
|
23
|
+
const _initializedInstant = new require_primordials_map_set.WeakSetCtor();
|
|
24
|
+
const _instantNanoseconds = new require_primordials_map_set.WeakMapCtor();
|
|
24
25
|
/**
|
|
25
26
|
* Read `[[Nanoseconds]]`. Caller MUST gate on `hasInstantSlot` first; behaviour
|
|
26
27
|
* on absent-slot input is undefined.
|
package/dist/themes/context.js
CHANGED
|
@@ -19,9 +19,9 @@ function emitThemeChange(theme) {
|
|
|
19
19
|
*
|
|
20
20
|
* @private
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
23
23
|
function getAsyncHooks() {
|
|
24
|
-
if (_async_hooks === void 0) _async_hooks =
|
|
24
|
+
if (_async_hooks === void 0) _async_hooks = /*@__PURE__*/ require("node:async_hooks");
|
|
25
25
|
return _async_hooks;
|
|
26
26
|
}
|
|
27
27
|
/**
|
package/dist/url/parse.js
CHANGED
|
@@ -19,7 +19,7 @@ const UrlCtor = URL;
|
|
|
19
19
|
* createRelativeUrl('/api/test', { base: 'https://example.com' }) // 'https://example.com/api/test'
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
|
-
|
|
22
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
23
23
|
function createRelativeUrl(path, options) {
|
|
24
24
|
const { base = "" } = {
|
|
25
25
|
__proto__: null,
|
|
@@ -42,7 +42,7 @@ function createRelativeUrl(path, options) {
|
|
|
42
42
|
* parseUrl('invalid') // undefined
|
|
43
43
|
* ```
|
|
44
44
|
*/
|
|
45
|
-
|
|
45
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
46
46
|
function parseUrl(value) {
|
|
47
47
|
try {
|
|
48
48
|
return new UrlCtor(value);
|
package/dist/url/predicates.js
CHANGED
|
@@ -18,7 +18,7 @@ const require_url_parse = require('./parse.js');
|
|
|
18
18
|
* isUrl(null) // false
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
|
21
|
-
|
|
21
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
22
22
|
function isUrl(value) {
|
|
23
23
|
return (typeof value === "string" && value !== "" || value !== null && typeof value === "object") && !!/* @__PURE__ */ require_url_parse.parseUrl(value);
|
|
24
24
|
}
|
|
@@ -20,7 +20,7 @@ const BooleanCtor = Boolean;
|
|
|
20
20
|
* urlSearchParamsAsArray(null) // []
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
24
24
|
function urlSearchParamsAsArray(value) {
|
|
25
25
|
return typeof value === "string" ? value.trim().split(/, */).map((v) => v.trim()).filter(BooleanCtor) : [];
|
|
26
26
|
}
|
|
@@ -34,7 +34,7 @@ function urlSearchParamsAsArray(value) {
|
|
|
34
34
|
* urlSearchParamsAsBoolean(null) // false
|
|
35
35
|
* ```
|
|
36
36
|
*/
|
|
37
|
-
|
|
37
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
38
38
|
function urlSearchParamsAsBoolean(value, options) {
|
|
39
39
|
const { defaultValue = false } = {
|
|
40
40
|
__proto__: null,
|
|
@@ -59,7 +59,7 @@ function urlSearchParamsAsBoolean(value, options) {
|
|
|
59
59
|
* urlSearchParamsAsNumber(params, 'other') // 0
|
|
60
60
|
* ```
|
|
61
61
|
*/
|
|
62
|
-
|
|
62
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
63
63
|
function urlSearchParamsAsNumber(params, key, options) {
|
|
64
64
|
const { defaultValue = 0 } = {
|
|
65
65
|
__proto__: null,
|
|
@@ -84,7 +84,7 @@ function urlSearchParamsAsNumber(params, key, options) {
|
|
|
84
84
|
* urlSearchParamsAsString(params, 'other') // ''
|
|
85
85
|
* ```
|
|
86
86
|
*/
|
|
87
|
-
|
|
87
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
88
88
|
function urlSearchParamsAsString(params, key, options) {
|
|
89
89
|
const { defaultValue = "" } = {
|
|
90
90
|
__proto__: null,
|
|
@@ -105,7 +105,7 @@ function urlSearchParamsAsString(params, key, options) {
|
|
|
105
105
|
* urlSearchParamsGetArray(params, 'tags') // ['a', 'b', 'c']
|
|
106
106
|
* ```
|
|
107
107
|
*/
|
|
108
|
-
|
|
108
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
109
109
|
function urlSearchParamsGetArray(params, key) {
|
|
110
110
|
if (params && typeof params.getAll === "function") {
|
|
111
111
|
const values = params.getAll(key);
|
|
@@ -125,7 +125,7 @@ function urlSearchParamsGetArray(params, key) {
|
|
|
125
125
|
* urlSearchParamsGetBoolean(params, 'other') // false
|
|
126
126
|
* ```
|
|
127
127
|
*/
|
|
128
|
-
|
|
128
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
129
129
|
function urlSearchParamsGetBoolean(params, key, options) {
|
|
130
130
|
const { defaultValue = false } = {
|
|
131
131
|
__proto__: null,
|
package/dist/words/article.js
CHANGED
|
@@ -16,7 +16,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
16
16
|
* determineArticle('banana') // 'a'
|
|
17
17
|
* ```
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
20
20
|
function determineArticle(word) {
|
|
21
21
|
return /^[aeiou]/i.test(word) ? "an" : "a";
|
|
22
22
|
}
|
package/dist/words/capitalize.js
CHANGED
|
@@ -17,7 +17,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
17
17
|
* capitalize('') // ''
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
|
-
|
|
20
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
21
21
|
function capitalize(word) {
|
|
22
22
|
if (word.length === 0) return word;
|
|
23
23
|
const [first, ...rest] = [...word];
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file
|
|
3
|
-
*
|
|
2
|
+
* @file Count-based pluralization. Two modes:
|
|
3
|
+
*
|
|
4
|
+
* - Default: appends a trailing `'s'` when the count is anything other than 1.
|
|
5
|
+
* Zero-cost; no Intl dependency on the hot path.
|
|
6
|
+
* - Dictionary: when `options.forms` is given, selects from a caller-supplied
|
|
7
|
+
* dictionary of forms keyed by plural category. Honors locale + cardinal /
|
|
8
|
+
* ordinal via `Intl.PluralRules`. Required `plural` acts as the fallback
|
|
9
|
+
* for any category not explicitly listed.
|
|
4
10
|
*/
|
|
5
11
|
import type { PluralizeOptions } from './types';
|
|
12
|
+
export declare function getRules(locale: string, type: Intl.PluralRuleType): Intl.PluralRules;
|
|
6
13
|
/**
|
|
7
14
|
* Pluralize a word based on count.
|
|
8
15
|
*
|
|
@@ -11,6 +18,21 @@ import type { PluralizeOptions } from './types';
|
|
|
11
18
|
* pluralize('file') // 'file'
|
|
12
19
|
* pluralize('file', { count: 3 }) // 'files'
|
|
13
20
|
* pluralize('file', { count: 0 }) // 'files'
|
|
21
|
+
*
|
|
22
|
+
* // Dictionary mode for irregulars.
|
|
23
|
+
* pluralize('child', {
|
|
24
|
+
* count: 3,
|
|
25
|
+
* forms: { singular: 'child', plural: 'children' },
|
|
26
|
+
* }) // 'children'
|
|
27
|
+
*
|
|
28
|
+
* // Locale + cardinal/ordinal. `singular` here covers CLDR's `one`
|
|
29
|
+
* // category (the count===1 ordinal suffix); `two`/`few` map directly;
|
|
30
|
+
* // `plural` is the fallback for everything else.
|
|
31
|
+
* pluralize('place', {
|
|
32
|
+
* count: 2,
|
|
33
|
+
* type: 'ordinal',
|
|
34
|
+
* forms: { singular: 'st', two: 'nd', few: 'rd', plural: 'th' },
|
|
35
|
+
* }) // 'nd'
|
|
14
36
|
* ```
|
|
15
37
|
*/
|
|
16
38
|
export declare function pluralize(word: string, options?: PluralizeOptions | undefined): string;
|
package/dist/words/pluralize.js
CHANGED
|
@@ -3,6 +3,24 @@
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
5
|
//#region src/words/pluralize.ts
|
|
6
|
+
const CLDR_TO_FIELD = {
|
|
7
|
+
one: "singular",
|
|
8
|
+
other: "plural",
|
|
9
|
+
zero: "zero",
|
|
10
|
+
two: "two",
|
|
11
|
+
few: "few",
|
|
12
|
+
many: "many"
|
|
13
|
+
};
|
|
14
|
+
const RULES_CACHE = /* @__PURE__ */ new Map();
|
|
15
|
+
function getRules(locale, type) {
|
|
16
|
+
const key = `${locale}:${type}`;
|
|
17
|
+
let r = RULES_CACHE.get(key);
|
|
18
|
+
if (!r) {
|
|
19
|
+
r = new Intl.PluralRules(locale, { type });
|
|
20
|
+
RULES_CACHE.set(key, r);
|
|
21
|
+
}
|
|
22
|
+
return r;
|
|
23
|
+
}
|
|
6
24
|
/**
|
|
7
25
|
* Pluralize a word based on count.
|
|
8
26
|
*
|
|
@@ -11,16 +29,33 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
11
29
|
* pluralize('file') // 'file'
|
|
12
30
|
* pluralize('file', { count: 3 }) // 'files'
|
|
13
31
|
* pluralize('file', { count: 0 }) // 'files'
|
|
32
|
+
*
|
|
33
|
+
* // Dictionary mode for irregulars.
|
|
34
|
+
* pluralize('child', {
|
|
35
|
+
* count: 3,
|
|
36
|
+
* forms: { singular: 'child', plural: 'children' },
|
|
37
|
+
* }) // 'children'
|
|
38
|
+
*
|
|
39
|
+
* // Locale + cardinal/ordinal. `singular` here covers CLDR's `one`
|
|
40
|
+
* // category (the count===1 ordinal suffix); `two`/`few` map directly;
|
|
41
|
+
* // `plural` is the fallback for everything else.
|
|
42
|
+
* pluralize('place', {
|
|
43
|
+
* count: 2,
|
|
44
|
+
* type: 'ordinal',
|
|
45
|
+
* forms: { singular: 'st', two: 'nd', few: 'rd', plural: 'th' },
|
|
46
|
+
* }) // 'nd'
|
|
14
47
|
* ```
|
|
15
48
|
*/
|
|
16
|
-
|
|
49
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
17
50
|
function pluralize(word, options) {
|
|
18
|
-
const { count = 1 } = {
|
|
51
|
+
const { count = 1, forms, locale = "en-US", type = "cardinal" } = {
|
|
19
52
|
__proto__: null,
|
|
20
53
|
...options
|
|
21
54
|
};
|
|
55
|
+
if (forms) return forms[CLDR_TO_FIELD[getRules(locale, type).select(count)]] ?? forms.plural;
|
|
22
56
|
return count === 1 ? word : `${word}s`;
|
|
23
57
|
}
|
|
24
58
|
|
|
25
59
|
//#endregion
|
|
60
|
+
exports.getRules = getRules;
|
|
26
61
|
exports.pluralize = pluralize;
|
package/dist/words/types.d.ts
CHANGED
|
@@ -1,7 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file Public type surface for `words/*` modules — the `PluralizeOptions`
|
|
3
|
-
* record. Pure types, no runtime side
|
|
3
|
+
* record and its `PluralForms` companion. Pure types, no runtime side
|
|
4
|
+
* effects.
|
|
4
5
|
*/
|
|
6
|
+
/**
|
|
7
|
+
* Count-aware forms for {@link pluralize}. `singular` covers the CLDR `one`
|
|
8
|
+
* category; `plural` covers the required `other` category and is the fallback
|
|
9
|
+
* when a count's category isn't explicitly listed. The remaining four
|
|
10
|
+
* (`zero`/`two`/`few`/`many`) are optional and default to `plural` when omitted
|
|
11
|
+
* — only languages like Arabic, Russian, or Welsh exercise them.
|
|
12
|
+
*
|
|
13
|
+
* Plural-category reference:
|
|
14
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules/select
|
|
15
|
+
* https://cldr.unicode.org/index/cldr-spec/plural-rules.
|
|
16
|
+
*/
|
|
17
|
+
export interface PluralForms {
|
|
18
|
+
singular?: string | undefined;
|
|
19
|
+
plural: string;
|
|
20
|
+
zero?: string | undefined;
|
|
21
|
+
two?: string | undefined;
|
|
22
|
+
few?: string | undefined;
|
|
23
|
+
many?: string | undefined;
|
|
24
|
+
}
|
|
5
25
|
export interface PluralizeOptions {
|
|
6
|
-
count?: number;
|
|
26
|
+
count?: number | undefined;
|
|
27
|
+
forms?: PluralForms | undefined;
|
|
28
|
+
locale?: string | undefined;
|
|
29
|
+
type?: Intl.PluralRuleType | undefined;
|
|
7
30
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@socketsecurity/lib",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.6",
|
|
4
4
|
"description": "Core utilities and infrastructure for Socket.dev security tools",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Socket.dev",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"url": "git+https://github.com/SocketDev/socket-lib.git"
|
|
21
21
|
},
|
|
22
22
|
"bin": {
|
|
23
|
+
"prim": "./dist/bin/prim.cjs",
|
|
23
24
|
"socket-lib": "./dist/bin/socket-lib.js"
|
|
24
25
|
},
|
|
25
26
|
"files": [
|
|
@@ -1064,6 +1065,11 @@
|
|
|
1064
1065
|
"types": "./dist/external-tools/from-download.d.ts",
|
|
1065
1066
|
"default": "./dist/external-tools/from-download.js"
|
|
1066
1067
|
},
|
|
1068
|
+
"./external-tools/from-pip-venv": {
|
|
1069
|
+
"source": "./src/external-tools/from-pip-venv.ts",
|
|
1070
|
+
"types": "./dist/external-tools/from-pip-venv.d.ts",
|
|
1071
|
+
"default": "./dist/external-tools/from-pip-venv.js"
|
|
1072
|
+
},
|
|
1067
1073
|
"./external-tools/janus/asset-names": {
|
|
1068
1074
|
"source": "./src/external-tools/janus/asset-names.ts",
|
|
1069
1075
|
"types": "./dist/external-tools/janus/asset-names.d.ts",
|
|
@@ -1199,6 +1205,31 @@
|
|
|
1199
1205
|
"types": "./dist/external-tools/sbt/types.d.ts",
|
|
1200
1206
|
"default": "./dist/external-tools/sbt/types.js"
|
|
1201
1207
|
},
|
|
1208
|
+
"./external-tools/skillspector/from-dlx": {
|
|
1209
|
+
"source": "./src/external-tools/skillspector/from-dlx.ts",
|
|
1210
|
+
"types": "./dist/external-tools/skillspector/from-dlx.d.ts",
|
|
1211
|
+
"default": "./dist/external-tools/skillspector/from-dlx.js"
|
|
1212
|
+
},
|
|
1213
|
+
"./external-tools/skillspector/from-path": {
|
|
1214
|
+
"source": "./src/external-tools/skillspector/from-path.ts",
|
|
1215
|
+
"types": "./dist/external-tools/skillspector/from-path.d.ts",
|
|
1216
|
+
"default": "./dist/external-tools/skillspector/from-path.js"
|
|
1217
|
+
},
|
|
1218
|
+
"./external-tools/skillspector/from-vfs": {
|
|
1219
|
+
"source": "./src/external-tools/skillspector/from-vfs.ts",
|
|
1220
|
+
"types": "./dist/external-tools/skillspector/from-vfs.d.ts",
|
|
1221
|
+
"default": "./dist/external-tools/skillspector/from-vfs.js"
|
|
1222
|
+
},
|
|
1223
|
+
"./external-tools/skillspector/resolve": {
|
|
1224
|
+
"source": "./src/external-tools/skillspector/resolve.ts",
|
|
1225
|
+
"types": "./dist/external-tools/skillspector/resolve.d.ts",
|
|
1226
|
+
"default": "./dist/external-tools/skillspector/resolve.js"
|
|
1227
|
+
},
|
|
1228
|
+
"./external-tools/skillspector/types": {
|
|
1229
|
+
"source": "./src/external-tools/skillspector/types.ts",
|
|
1230
|
+
"types": "./dist/external-tools/skillspector/types.d.ts",
|
|
1231
|
+
"default": "./dist/external-tools/skillspector/types.js"
|
|
1232
|
+
},
|
|
1202
1233
|
"./external-tools/synp/asset-names": {
|
|
1203
1234
|
"source": "./src/external-tools/synp/asset-names.ts",
|
|
1204
1235
|
"types": "./dist/external-tools/synp/asset-names.d.ts",
|
|
@@ -2799,13 +2830,14 @@
|
|
|
2799
2830
|
"@npmcli/arborist": "9.1.4",
|
|
2800
2831
|
"@npmcli/package-json": "7.0.0",
|
|
2801
2832
|
"@npmcli/promise-spawn": "8.0.3",
|
|
2833
|
+
"@redwoodjs/agent-ci": "0.16.2",
|
|
2802
2834
|
"@sinclair/typebox": "0.34.49",
|
|
2803
2835
|
"@socketregistry/is-unicode-supported": "1.0.5",
|
|
2804
2836
|
"@socketregistry/packageurl-js": "npm:@socketregistry/packageurl-js@1.4.2",
|
|
2805
2837
|
"@socketregistry/packageurl-js-stable": "npm:@socketregistry/packageurl-js@1.4.2",
|
|
2806
2838
|
"@socketregistry/yocto-spinner": "1.0.25",
|
|
2807
|
-
"@socketsecurity/lib": "npm:@socketsecurity/lib@6.0.
|
|
2808
|
-
"@socketsecurity/lib-stable": "npm:@socketsecurity/lib@6.0.
|
|
2839
|
+
"@socketsecurity/lib": "npm:@socketsecurity/lib@6.0.4",
|
|
2840
|
+
"@socketsecurity/lib-stable": "npm:@socketsecurity/lib@6.0.5",
|
|
2809
2841
|
"@socketsecurity/sdk": "npm:@socketsecurity/sdk@4.0.1",
|
|
2810
2842
|
"@socketsecurity/sdk-stable": "npm:@socketsecurity/sdk@4.0.1",
|
|
2811
2843
|
"@types/node": "24.9.2",
|
|
@@ -2837,7 +2869,7 @@
|
|
|
2837
2869
|
"pacote": "21.5.0",
|
|
2838
2870
|
"picomatch": "4.0.4",
|
|
2839
2871
|
"pony-cause": "2.1.11",
|
|
2840
|
-
"rolldown": "1.0.
|
|
2872
|
+
"rolldown": "1.0.3",
|
|
2841
2873
|
"semver": "7.7.2",
|
|
2842
2874
|
"shell-quote": "1.8.4",
|
|
2843
2875
|
"signal-exit": "4.1.0",
|
|
@@ -2871,6 +2903,13 @@
|
|
|
2871
2903
|
"npm": ">=11.16.0",
|
|
2872
2904
|
"pnpm": ">=11.4.0"
|
|
2873
2905
|
},
|
|
2906
|
+
"allowScripts": {
|
|
2907
|
+
"cpu-features": false,
|
|
2908
|
+
"esbuild": true,
|
|
2909
|
+
"protobufjs": false,
|
|
2910
|
+
"rolldown": true,
|
|
2911
|
+
"ssh2": false
|
|
2912
|
+
},
|
|
2874
2913
|
"scripts": {
|
|
2875
2914
|
"build": "node scripts/build/cli.mts",
|
|
2876
2915
|
"check": "node scripts/check.mts",
|
|
@@ -2888,6 +2927,7 @@
|
|
|
2888
2927
|
"update": "node scripts/update.mts",
|
|
2889
2928
|
"lockstep": "node scripts/lockstep.mts",
|
|
2890
2929
|
"lockstep:emit-schema": "node scripts/lockstep-emit-schema.mts",
|
|
2891
|
-
"setup-security-tools": "node .claude/hooks/setup-security-tools/install.mts"
|
|
2930
|
+
"setup-security-tools": "node .claude/hooks/fleet/setup-security-tools/install.mts",
|
|
2931
|
+
"ci:local": "agent-ci run --all"
|
|
2892
2932
|
}
|
|
2893
2933
|
}
|