MCPcopy Create free account
hub / github.com/jshttp/cookie / valueSliceDoThenWhileEmptyString

Function valueSliceDoThenWhileEmptyString

benchmarks/value-slice.bench.ts:60–80  ·  view source on GitHub ↗
(
  str: string,
  min: number,
  max: number,
)

Source from the content-addressed store, hash-verified

58}
59
60function valueSliceDoThenWhileEmptyString(
61 str: string,
62 min: number,
63 max: number,
64) {
65 let start = min;
66 let end = max;
67
68 do {
69 const code = str.charCodeAt(start);
70 if (code !== 32 /* */ && code !== 9 /* \t */) break;
71 } while (++start < end);
72
73 while (end > start) {
74 const code = str.charCodeAt(end - 1);
75 if (code !== 32 /* */ && code !== 9 /* \t */) break;
76 end--;
77 }
78
79 return start === end ? "" : str.slice(start, end);
80}
81
82function valueSliceDoThenWhileExitEarly(str: string, min: number, max: number) {
83 if (min === max) return "";

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…