@effected/github-actions 0.34.0 → 0.36.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.
Files changed (46) hide show
  1. package/Action.js +10 -10
  2. package/ActionCache.js +17 -40
  3. package/ActionEnvironment.js +1 -1
  4. package/ActionInput.js +1 -1
  5. package/ActionLogger.js +197 -64
  6. package/ActionManifest.js +2 -2
  7. package/ActionOutputs.js +2 -2
  8. package/ActionState.js +1 -1
  9. package/ActionsIdentityToken.js +2 -2
  10. package/ActionsProvenance.js +2 -2
  11. package/ActionsRegistryCredential.js +2 -2
  12. package/Artifact.js +16 -39
  13. package/BlobStore.githubCache.js +16 -42
  14. package/BlobStore.js +4 -4
  15. package/CacheKey.js +2 -2
  16. package/CheckDocument.js +1 -1
  17. package/Checkout.js +361 -0
  18. package/DetachedProcess.js +4 -4
  19. package/DryRun.js +1 -1
  20. package/GitHubMarkdown.js +1 -1
  21. package/GitHubToken.js +2 -2
  22. package/ManagedDocument.js +1 -1
  23. package/OidcTokenIssuer.js +7 -7
  24. package/PackageManagerInstaller.js +3 -3
  25. package/README.md +4 -3
  26. package/Secret.js +1 -1
  27. package/ToolInstaller.js +4 -4
  28. package/index.d.ts +602 -119
  29. package/index.js +3 -2
  30. package/internal/actionsResults.js +1 -1
  31. package/internal/blobCause.js +2 -80
  32. package/internal/blobTransport.js +172 -0
  33. package/internal/cacheService.js +1 -1
  34. package/internal/checkout/asciiTrim.js +18 -0
  35. package/internal/checkout/credentials.js +563 -0
  36. package/internal/checkout/directory.js +119 -0
  37. package/internal/checkout/inputs.js +130 -0
  38. package/internal/checkout/refs.js +143 -0
  39. package/internal/checkout/settings.js +144 -0
  40. package/internal/checkout/source.js +418 -0
  41. package/internal/checkout/unsafePullRequest.js +62 -0
  42. package/internal/digest.js +1 -1
  43. package/internal/pnpmExe.js +1 -1
  44. package/internal/stepLog.js +225 -0
  45. package/internal/twirp.js +1 -1
  46. package/package.json +6 -6
package/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { WorkflowCommand } from "@effected/github-commands";
1
2
  import { Action, ActionRuntime, describeCause } from "./Action.js";
2
3
  import { ActionCache, ActionCacheError } from "./ActionCache.js";
3
4
  import { ActionEnvironment, ActionEnvironmentError, GitHubContext, RunnerContext } from "./ActionEnvironment.js";
@@ -16,6 +17,7 @@ import { BlobStore, BlobStoreError } from "./BlobStore.js";
16
17
  import { BlobTransferError } from "./BlobTransfer.js";
17
18
  import { CacheKey, CacheKeyBadPatternError, CacheKeyReadError } from "./CacheKey.js";
18
19
  import { CheckDocument, CheckDocumentError, CheckDocumentStamp, CheckReport } from "./CheckDocument.js";
20
+ import { Checkout, CheckoutAuth, CheckoutAuthError, CheckoutCommitMismatchError, CheckoutDefaultBranchError, CheckoutGitTooOldError, CheckoutPathError, CheckoutRef, CheckoutRefNotFoundError, CheckoutResult, CheckoutServerUrlError, CheckoutStateKeyInUseError, CheckoutUnqualifiedRefPinError, CheckoutUnsafePullRequestError } from "./Checkout.js";
19
21
  import { CheckState, projectCheckState } from "./CheckState.js";
20
22
  import { ChildEnv } from "./ChildEnv.js";
21
23
  import { DetachedLogUnavailableError, DetachedNotReadyError, DetachedProcess, DetachedSignalFailedError, DetachedSpawnFailedError, InvalidPidError, ProcessId } from "./DetachedProcess.js";
@@ -27,6 +29,5 @@ import { OidcTokenError, OidcTokenIssuer } from "./OidcTokenIssuer.js";
27
29
  import { AmbientPackageManager, CachedPackageManager, InstalledPackageManager, PackageManagerInstaller, PackageManagerInstallerError } from "./PackageManagerInstaller.js";
28
30
  import { Secret } from "./Secret.js";
29
31
  import { ToolInstaller, ToolInstallerError } from "./ToolInstaller.js";
30
- import { WorkflowCommand } from "@effected/github-commands";
31
32
 
32
- export { Action, ActionCache, ActionCacheError, ActionEnvironment, ActionEnvironmentError, ActionInput, ActionLogger, ActionManifest, ActionManifestBranding, ActionManifestCompositeRuns, ActionManifestDecodeError, ActionManifestDiff, ActionManifestDockerRuns, ActionManifestInput, ActionManifestNodeRuns, ActionManifestOutput, ActionManifestReadError, ActionOutputs, ActionRuntime, ActionState, ActionStateError, ActionsIdentityToken, ActionsProvenance, ActionsRegistryCredential, AmbientPackageManager, Artifact, ArtifactError, BlobEnvelope, BlobMetadataDecodeError, BlobMetadataEncodeError, BlobStore, BlobStoreError, BlobTransferError, CacheKey, CacheKeyBadPatternError, CacheKeyReadError, CachedPackageManager, CheckDocument, CheckDocumentError, CheckDocumentStamp, CheckReport, CheckState, ChildEnv, DetachedLogUnavailableError, DetachedNotReadyError, DetachedOutputError, DetachedProcess, DetachedSignalFailedError, DetachedSpawnFailedError, DryRun, GitHubCacheBlobStore, GitHubContext, GitHubMarkdown, GitHubToken, GitHubTokenError, InstalledPackageManager, InvalidOutputNameError, InvalidPidError, ManagedDocument, ManagedDocumentError, NotABlobEnvelopeError, OidcTokenError, OidcTokenIssuer, OutputEncodeError, PackageManagerInstaller, PackageManagerInstallerError, ProcessId, RecordedOutput, RunnerContext, RunnerFileUnavailableError, RunnerFileWriteError, Secret, ToolInstaller, ToolInstallerError, TruncatedBlobEnvelopeError, UnsupportedBlobEnvelopeVersionError, WorkflowCommand, describeCause, projectCheckState };
33
+ export { Action, ActionCache, ActionCacheError, ActionEnvironment, ActionEnvironmentError, ActionInput, ActionLogger, ActionManifest, ActionManifestBranding, ActionManifestCompositeRuns, ActionManifestDecodeError, ActionManifestDiff, ActionManifestDockerRuns, ActionManifestInput, ActionManifestNodeRuns, ActionManifestOutput, ActionManifestReadError, ActionOutputs, ActionRuntime, ActionState, ActionStateError, ActionsIdentityToken, ActionsProvenance, ActionsRegistryCredential, AmbientPackageManager, Artifact, ArtifactError, BlobEnvelope, BlobMetadataDecodeError, BlobMetadataEncodeError, BlobStore, BlobStoreError, BlobTransferError, CacheKey, CacheKeyBadPatternError, CacheKeyReadError, CachedPackageManager, CheckDocument, CheckDocumentError, CheckDocumentStamp, CheckReport, CheckState, Checkout, CheckoutAuth, CheckoutAuthError, CheckoutCommitMismatchError, CheckoutDefaultBranchError, CheckoutGitTooOldError, CheckoutPathError, CheckoutRef, CheckoutRefNotFoundError, CheckoutResult, CheckoutServerUrlError, CheckoutStateKeyInUseError, CheckoutUnqualifiedRefPinError, CheckoutUnsafePullRequestError, ChildEnv, DetachedLogUnavailableError, DetachedNotReadyError, DetachedOutputError, DetachedProcess, DetachedSignalFailedError, DetachedSpawnFailedError, DryRun, GitHubCacheBlobStore, GitHubContext, GitHubMarkdown, GitHubToken, GitHubTokenError, InstalledPackageManager, InvalidOutputNameError, InvalidPidError, ManagedDocument, ManagedDocumentError, NotABlobEnvelopeError, OidcTokenError, OidcTokenIssuer, OutputEncodeError, PackageManagerInstaller, PackageManagerInstallerError, ProcessId, RecordedOutput, RunnerContext, RunnerFileUnavailableError, RunnerFileWriteError, Secret, ToolInstaller, ToolInstallerError, TruncatedBlobEnvelopeError, UnsupportedBlobEnvelopeVersionError, WorkflowCommand, describeCause, projectCheckState };
@@ -1,5 +1,5 @@
1
- import { Effect, Option, Redacted, Result } from "effect";
2
1
  import { Jws } from "@effected/jwt";
2
+ import { Effect, Option, Redacted, Result } from "effect";
3
3
 
4
4
  // src/internal/actionsResults.ts
5
5
  /** The variable naming the backend. Absent outside a `uses:` step. */
@@ -1,9 +1,7 @@
1
- import { Predicate } from "effect";
2
- import { UrlParams } from "effect/http";
3
1
  import { HttpRedaction } from "@effected/crypto";
2
+ import { UrlParams } from "effect/http";
4
3
 
5
4
  // src/internal/blobCause.ts
6
- const REDACTED = "REDACTED";
7
5
  const SAS_NAMES = [
8
6
  "sig",
9
7
  "se",
@@ -20,81 +18,5 @@ const SAS_NAMES = [
20
18
  ];
21
19
  /** A signed blob url with its SAS credential fields and userinfo redacted. */
22
20
  const blobUrl = (raw) => UrlParams.redactUrl(HttpRedaction.url(raw), SAS_NAMES);
23
- const text = (raw) => HttpRedaction.text(raw).replace(/https?:\/\/[^\s"'<>`]+/gi, (match) => UrlParams.redactUrl(match, SAS_NAMES));
24
- /** A header record (`details`, or a response's headers) minus cookies, sensitive values redacted. */
25
- const headerRecord = (input) => {
26
- const entries = headerEntries(input);
27
- if (entries === void 0) return void 0;
28
- const out = {};
29
- for (const [name, value] of entries) {
30
- const lower = name.toLowerCase();
31
- if (lower === "set-cookie" || lower === "cookie") continue;
32
- if (typeof value === "string") out[name] = HttpRedaction.isSensitiveHeader(lower) ? REDACTED : text(value);
33
- else if (Predicate.isNumber(value) || Predicate.isBoolean(value)) out[name] = value;
34
- }
35
- return out;
36
- };
37
- const headerEntries = (input) => {
38
- if (input === null || typeof input !== "object") return void 0;
39
- if (Predicate.hasProperty(input, "toJSON") && typeof input.toJSON === "function") {
40
- const json = input.toJSON();
41
- return json !== null && typeof json === "object" ? Object.entries(json) : void 0;
42
- }
43
- return Object.entries(input);
44
- };
45
- const isRestShaped = (value) => Predicate.hasProperty(value, "request") || Predicate.hasProperty(value, "response");
46
- const MAX_DEPTH = 8;
47
- const define = (target, key, value, enumerable) => {
48
- Object.defineProperty(target, key, {
49
- value,
50
- enumerable,
51
- writable: true,
52
- configurable: true
53
- });
54
- };
55
- const copy = (value, depth) => {
56
- if (typeof value === "string") return text(value);
57
- if (value === null || typeof value !== "object") return value;
58
- if (depth >= MAX_DEPTH) return void 0;
59
- const source = value;
60
- const out = value instanceof Error ? Object.create(Object.getPrototypeOf(value)) : new Error(text(typeof source.message === "string" ? source.message : Object.prototype.toString.call(value)));
61
- if (value instanceof Error) {
62
- define(out, "message", text(value.message), false);
63
- if (value.stack !== void 0) define(out, "stack", text(value.stack), false);
64
- }
65
- for (const [key, field] of Object.entries(source)) if (key === "details") {
66
- const details = headerRecord(field);
67
- if (details !== void 0) define(out, key, details, true);
68
- } else if (typeof field === "string") define(out, key, text(field), true);
69
- else if (Predicate.isNumber(field) || Predicate.isBoolean(field)) define(out, key, field, true);
70
- const request = Predicate.hasProperty(value, "request") ? asRecord(value.request) : void 0;
71
- if (request !== void 0) define(out, "request", {
72
- ...typeof request.method === "string" ? { method: request.method } : {},
73
- ...typeof request.url === "string" ? { url: blobUrl(request.url) } : {},
74
- ...headerRecord(request.headers) !== void 0 ? { headers: headerRecord(request.headers) } : {}
75
- }, false);
76
- const response = Predicate.hasProperty(value, "response") ? asRecord(value.response) : void 0;
77
- if (response !== void 0) define(out, "response", {
78
- ...Predicate.isNumber(response.status) ? { status: response.status } : {},
79
- ...headerRecord(response.headers) !== void 0 ? { headers: headerRecord(response.headers) } : {}
80
- }, false);
81
- if (Predicate.hasProperty(value, "cause") && value.cause !== void 0) {
82
- const nested = copy(value.cause, depth + 1);
83
- if (nested !== void 0) define(out, "cause", nested, true);
84
- }
85
- return out;
86
- };
87
- const asRecord = (value) => value !== null && typeof value === "object" ? value : void 0;
88
- /**
89
- * Sanitize what a blob transfer threw before keeping it as a cause: a
90
- * `RestError`-shaped value (one carrying a `request` or `response`) becomes a
91
- * copy on the same prototype that keeps `name`, `message`, `code`,
92
- * `statusCode`, the method, the url with its SAS credential fields redacted,
93
- * and the headers minus `set-cookie`, with sensitive values redacted; the
94
- * request and response bodies, the pipeline options and the raw url are gone.
95
- * Anything else — a filesystem error writing the download, a kit error — is
96
- * returned unchanged, by identity.
97
- */
98
- const blobCause = (cause) => cause !== null && typeof cause === "object" && isRestShaped(cause) ? copy(cause, 0) : cause;
99
21
 
100
- export { blobCause, blobUrl };
22
+ export { blobUrl };
@@ -0,0 +1,172 @@
1
+ import { Effect, PlatformError, Schedule, Stream } from "effect";
2
+ import { HttpBody, HttpClientRequest } from "effect/http";
3
+ import { BlobTransferError } from "../BlobTransfer.js";
4
+ import { blobUrl } from "./blobCause.js";
5
+
6
+ // src/internal/blobTransport.ts
7
+ /**
8
+ * The storage service version sent as `x-ms-version`.
9
+ *
10
+ * @remarks
11
+ * The version `@azure/storage-blob` 12.34 sent, which is the one the transport
12
+ * replaced. A SAS url's own `sv` governs what the signature authorizes; this
13
+ * header selects the REST behaviour of the call.
14
+ *
15
+ * @internal
16
+ */
17
+ const SERVICE_VERSION = "2026-10-06";
18
+ const MIB = 1048576;
19
+ /** The sizing `ActionCache` and `Artifact` upload files with. @internal */
20
+ const FILE_OPTIONS = {
21
+ maxSingleShotSize: 128 * MIB,
22
+ blockSize: 64 * MIB,
23
+ concurrency: 8,
24
+ retrySchedule: Schedule.exponential("1 second", 2),
25
+ retries: 4
26
+ };
27
+ /** The sizing `BlobStore.githubCache` uploads buffers with. @internal */
28
+ const DATA_OPTIONS = {
29
+ ...FILE_OPTIONS,
30
+ maxSingleShotSize: 256 * MIB
31
+ };
32
+ /**
33
+ * Why a blob request did not succeed.
34
+ *
35
+ * @remarks
36
+ * A plain `Error` subclass rather than a Schema class: it is only ever kept as
37
+ * `BlobTransferError.cause`, and it holds nothing that was not redacted on the
38
+ * way in.
39
+ *
40
+ * @internal
41
+ */
42
+ var BlobRequestError = class extends Error {
43
+ name = "BlobRequestError";
44
+ method;
45
+ /** The request url with its SAS credential fields redacted. */
46
+ url;
47
+ /** The HTTP status, absent for a transport fault. */
48
+ statusCode;
49
+ /** The storage service's `<Code>`, read from an XML error body. */
50
+ code;
51
+ /** The `x-ms-request-id` the service answered with. */
52
+ requestId;
53
+ constructor(fields) {
54
+ super(fields.message);
55
+ this.method = fields.method;
56
+ this.url = blobUrl(fields.url);
57
+ if (fields.statusCode !== void 0) this.statusCode = fields.statusCode;
58
+ if (fields.code !== void 0) this.code = fields.code;
59
+ if (fields.requestId !== void 0) this.requestId = fields.requestId;
60
+ }
61
+ };
62
+ const isTransient = (error) => error.statusCode === void 0 || error.statusCode >= 500 || error.statusCode === 408 || error.statusCode === 429;
63
+ /** The service's `<Code>` out of an XML error body. */
64
+ const errorCode = (body) => /<Code>([^<]+)<\/Code>/.exec(body)?.[1];
65
+ const base = (method, url) => (method === "PUT" ? HttpClientRequest.put(url) : HttpClientRequest.get(url)).pipe(HttpClientRequest.setHeader("x-ms-version", SERVICE_VERSION));
66
+ /** Send one request; a non-2xx answer or a transport fault is a {@link BlobRequestError}. */
67
+ const send = (http, method, url, request) => http.execute(request).pipe(Effect.mapError((cause) => new BlobRequestError({
68
+ method,
69
+ url,
70
+ message: `${method} did not complete (${cause.reason._tag})`
71
+ })), Effect.flatMap((response) => {
72
+ if (response.status >= 200 && response.status < 300) return Effect.succeed(response);
73
+ return response.text.pipe(Effect.orElseSucceed(() => ""), Effect.flatMap((body) => Effect.fail(new BlobRequestError({
74
+ method,
75
+ url,
76
+ message: `${method} answered ${response.status}`,
77
+ statusCode: response.status,
78
+ code: errorCode(body),
79
+ requestId: response.headers["x-ms-request-id"]
80
+ }))));
81
+ }));
82
+ const withRetry = (options, attempt) => Effect.retry(attempt, {
83
+ schedule: options.retrySchedule,
84
+ times: options.retries,
85
+ while: (error) => error instanceof BlobRequestError && isTransient(error)
86
+ });
87
+ const putBody = (http, options, url, params, body, blobType) => {
88
+ const request = Object.entries(params).reduce((req, [name, value]) => HttpClientRequest.setUrlParam(req, name, value), base("PUT", url).pipe(HttpClientRequest.setBody(body)));
89
+ const typed = blobType ? HttpClientRequest.setHeader(request, "x-ms-blob-type", "BlockBlob") : request;
90
+ return withRetry(options, Effect.asVoid(Effect.scoped(send(http, "PUT", url, typed))));
91
+ };
92
+ /** The fixed-width base64 id of block `index`; every id in a blob must be one length. */
93
+ const blockId = (index) => btoa(String(index).padStart(8, "0"));
94
+ const blocklistXml = (count) => `<?xml version="1.0" encoding="utf-8"?><BlockList>${Array.from({ length: count }, (_, index) => `<Latest>${blockId(index)}</Latest>`).join("")}</BlockList>`;
95
+ /**
96
+ * Upload `size` bytes, whole or as blocks, reading each span with `read`.
97
+ *
98
+ * @remarks
99
+ * `read` runs once per block, outside the retry: a retried `PUT` sends the
100
+ * same bytes again, which a `Uint8Array` body can do and a consumed stream
101
+ * could not.
102
+ */
103
+ const upload = (http, options, url, size, read) => {
104
+ if (size <= options.maxSingleShotSize) return Effect.flatMap(read(0, size), (bytes) => putBody(http, options, url, {}, HttpBody.uint8Array(bytes, "application/octet-stream"), true));
105
+ const count = Math.ceil(size / options.blockSize);
106
+ return Effect.forEach(Array.from({ length: count }, (_, index) => index), (index) => Effect.flatMap(read(index * options.blockSize, Math.min(options.blockSize, size - index * options.blockSize)), (bytes) => putBody(http, options, url, {
107
+ comp: "block",
108
+ blockid: blockId(index)
109
+ }, HttpBody.uint8Array(bytes, "application/octet-stream"), false)), {
110
+ concurrency: options.concurrency,
111
+ discard: true
112
+ }).pipe(Effect.andThen(putBody(http, options, url, { comp: "blocklist" }, HttpBody.text(blocklistXml(count), "application/xml"), false)));
113
+ };
114
+ /**
115
+ * Read `length` bytes of `file` from `offset` into one buffer, written as each chunk arrives: the chunks are never
116
+ * held beside the joined copy, so a block costs its own size once. A file that ends early fails, rather than send
117
+ * zero bytes the signature would accept.
118
+ */
119
+ const readSpan = (fs, file, offset, length) => Effect.suspend(() => {
120
+ const out = new Uint8Array(length);
121
+ let at = 0;
122
+ return fs.stream(file, {
123
+ offset,
124
+ bytesToRead: length
125
+ }).pipe(Stream.runForEach((chunk) => Effect.sync(() => {
126
+ const take = Math.min(chunk.byteLength, length - at);
127
+ out.set(take === chunk.byteLength ? chunk : chunk.subarray(0, take), at);
128
+ at += take;
129
+ })), Effect.flatMap(() => at === length ? Effect.succeed(out) : Effect.fail(PlatformError.systemError({
130
+ _tag: "UnexpectedEof",
131
+ module: "FileSystem",
132
+ method: "stream",
133
+ description: `expected ${length} bytes at offset ${offset}, read ${at}`,
134
+ pathOrDescriptor: file
135
+ }))));
136
+ });
137
+ const uploadFailed = (cause) => new BlobTransferError({
138
+ reason: "uploadFailed",
139
+ cause
140
+ });
141
+ const downloadFailed = (cause) => new BlobTransferError({
142
+ reason: "downloadFailed",
143
+ cause
144
+ });
145
+ /**
146
+ * The {@link DataBlobTransfer} over `HttpClient`.
147
+ *
148
+ * @internal
149
+ */
150
+ const httpDataTransfer = (http, options = DATA_OPTIONS) => ({
151
+ uploadData: (url, data) => upload(http, options, url, data.byteLength, (offset, length) => Effect.succeed(data.subarray(offset, offset + length))).pipe(Effect.mapError(uploadFailed)),
152
+ downloadToBuffer: (url) => withRetry(options, Effect.scoped(Effect.flatMap(send(http, "GET", url, base("GET", url)), (response) => response.arrayBuffer.pipe(Effect.map((buffer) => new Uint8Array(buffer)), Effect.mapError((cause) => new BlobRequestError({
153
+ method: "GET",
154
+ url,
155
+ message: `GET body did not complete (${cause.reason._tag})`
156
+ })))))).pipe(Effect.mapError(downloadFailed))
157
+ });
158
+ /**
159
+ * The {@link FileBlobTransfer} over `HttpClient` and `FileSystem`.
160
+ *
161
+ * @internal
162
+ */
163
+ const httpFileTransfer = (http, fs, options = FILE_OPTIONS) => ({
164
+ uploadFile: (url, file) => Effect.flatMap(fs.stat(file), (info) => upload(http, options, url, Number(info.size), (offset, length) => readSpan(fs, file, offset, length))).pipe(Effect.mapError(uploadFailed)),
165
+ downloadToFile: (url, file) => withRetry(options, Effect.scoped(Effect.flatMap(send(http, "GET", url, base("GET", url)), (response) => response.stream.pipe(Stream.mapError((cause) => new BlobRequestError({
166
+ method: "GET",
167
+ url,
168
+ message: `GET body did not complete (${cause.reason._tag})`
169
+ })), Stream.run(fs.sink(file)))))).pipe(Effect.mapError(downloadFailed))
170
+ });
171
+
172
+ export { BlobRequestError, DATA_OPTIONS, FILE_OPTIONS, SERVICE_VERSION, httpDataTransfer, httpFileTransfer };
@@ -1,5 +1,5 @@
1
- import { CONFLICT, isOk, stringField } from "./twirp.js";
2
1
  import { Effect, Option } from "effect";
2
+ import { CONFLICT, isOk, stringField } from "./twirp.js";
3
3
 
4
4
  // src/internal/cacheService.ts
5
5
  /** The Twirp service the Actions cache protocol lives under. @internal */
@@ -0,0 +1,18 @@
1
+ // src/internal/checkout/asciiTrim.ts
2
+ const isAsciiWhitespace = (code) => code === 32 || code >= 9 && code <= 13;
3
+ /**
4
+ * Strips only the ASCII whitespace (`\t`, `\n`, `\v`, `\f`, `\r` and space) from both ends of a value. A BOM or an NBSP
5
+ * is valid inside a git ref name, so a wider trim would reclassify a fork branch named `"<BOM><sha>"` as a bare commit
6
+ * and slip past the unsafe pull request guard. A two-ended index scan, linear in the value's length.
7
+ *
8
+ * @internal
9
+ */
10
+ const asciiTrim = (value) => {
11
+ let start = 0;
12
+ let end = value.length;
13
+ while (start < end && isAsciiWhitespace(value.charCodeAt(start))) start++;
14
+ while (end > start && isAsciiWhitespace(value.charCodeAt(end - 1))) end--;
15
+ return start === 0 && end === value.length ? value : value.slice(start, end);
16
+ };
17
+
18
+ export { asciiTrim };