@sapphire/lexure
Advanced tools
Comparing version 1.1.8-next.5873dace.0 to 1.1.8-next.5ac3f246
@@ -7,6 +7,3 @@ var SapphireLexure = (function (exports) { | ||
var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); | ||
var __publicField = (obj, key, value) => { | ||
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); | ||
return value; | ||
}; | ||
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); | ||
@@ -17,6 +14,3 @@ // ../result/dist/esm/index.mjs | ||
var __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name", { value, configurable: true }), "__name"); | ||
var __publicField2 = /* @__PURE__ */ __name((obj, key, value) => { | ||
__defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value); | ||
return value; | ||
}, "__publicField"); | ||
var __publicField2 = /* @__PURE__ */ __name((obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value), "__publicField"); | ||
function isFunction(input) { | ||
@@ -140,4 +134,4 @@ return typeof input === "function"; | ||
return this.value.match({ | ||
some: (value) => createSome(createOk(value)), | ||
none: () => createNone | ||
some: /* @__PURE__ */ __name2((value) => createSome(createOk(value)), "some"), | ||
none: /* @__PURE__ */ __name2(() => createNone, "none") | ||
}); | ||
@@ -266,4 +260,4 @@ } | ||
return this.value.match({ | ||
ok: (v) => createOk(createSome(v)), | ||
err: (e) => createErr(e) | ||
ok: /* @__PURE__ */ __name2((v) => createOk(createSome(v)), "ok"), | ||
err: /* @__PURE__ */ __name2((e) => createErr(e), "err") | ||
}); | ||
@@ -542,6 +536,4 @@ } | ||
function resolve(value) { | ||
if (value === null || value === void 0) | ||
return Option2.none; | ||
if (is(value)) | ||
return value; | ||
if (value === null || value === void 0) return Option2.none; | ||
if (is(value)) return value; | ||
return (0, Option2.some)(value); | ||
@@ -558,4 +550,3 @@ } | ||
function from(op) { | ||
if (!isFunction(op)) | ||
return resolve(op); | ||
if (!isFunction(op)) return resolve(op); | ||
try { | ||
@@ -610,4 +601,3 @@ return resolve(op()); | ||
function resolve(value) { | ||
if (is(value)) | ||
return value; | ||
if (is(value)) return value; | ||
return (0, Result2.ok)(value); | ||
@@ -624,4 +614,3 @@ } | ||
function from(op) { | ||
if (!isFunction(op)) | ||
return resolve(op); | ||
if (!isFunction(op)) return resolve(op); | ||
try { | ||
@@ -731,4 +720,3 @@ return resolve(op()); | ||
single() { | ||
if (this.finished) | ||
return Option.none; | ||
if (this.finished) return Option.none; | ||
while (this.state.used.has(this.state.position)) { | ||
@@ -773,4 +761,3 @@ ++this.state.position; | ||
singleMap(predicate, useAnyways = false) { | ||
if (this.finished) | ||
return Option.none; | ||
if (this.finished) return Option.none; | ||
while (this.state.used.has(this.state.position)) { | ||
@@ -797,4 +784,3 @@ ++this.state.position; | ||
async singleMapAsync(predicate, useAnyways = false) { | ||
if (this.finished) | ||
return Option.none; | ||
if (this.finished) return Option.none; | ||
while (this.state.used.has(this.state.position)) { | ||
@@ -847,4 +833,3 @@ ++this.state.position; | ||
singleParse(predicate, useAnyways = false) { | ||
if (this.finished) | ||
return Result.err(null); | ||
if (this.finished) return Result.err(null); | ||
while (this.state.used.has(this.state.position)) { | ||
@@ -872,4 +857,3 @@ ++this.state.position; | ||
async singleParseAsync(predicate, useAnyways = false) { | ||
if (this.finished) | ||
return Result.err(null); | ||
if (this.finished) return Result.err(null); | ||
while (this.state.used.has(this.state.position)) { | ||
@@ -907,4 +891,3 @@ ++this.state.position; | ||
for (let i = from; i < this.length; ++i) { | ||
if (this.state.used.has(i)) | ||
continue; | ||
if (this.state.used.has(i)) continue; | ||
const parameter = this.results.ordered[i].value; | ||
@@ -940,4 +923,3 @@ if (predicate(parameter)) { | ||
for (let i = from; i < this.length; ++i) { | ||
if (this.state.used.has(i)) | ||
continue; | ||
if (this.state.used.has(i)) continue; | ||
const parameter = this.results.ordered[i].value; | ||
@@ -974,4 +956,3 @@ if (await predicate(parameter)) { | ||
for (let i = from; i < this.length; ++i) { | ||
if (this.state.used.has(i)) | ||
continue; | ||
if (this.state.used.has(i)) continue; | ||
const parameter = this.results.ordered[i].value; | ||
@@ -1009,4 +990,3 @@ const result = predicate(parameter); | ||
for (let i = from; i < this.length; ++i) { | ||
if (this.state.used.has(i)) | ||
continue; | ||
if (this.state.used.has(i)) continue; | ||
const parameter = this.results.ordered[i].value; | ||
@@ -1061,4 +1041,3 @@ const result = await predicate(parameter); | ||
for (let i = from; i < this.length; ++i) { | ||
if (this.state.used.has(i)) | ||
continue; | ||
if (this.state.used.has(i)) continue; | ||
const parameter = this.results.ordered[i].value; | ||
@@ -1091,4 +1070,3 @@ const result = predicate(parameter); | ||
for (let i = from; i < this.length; ++i) { | ||
if (this.state.used.has(i)) | ||
continue; | ||
if (this.state.used.has(i)) continue; | ||
const parameter = this.results.ordered[i].value; | ||
@@ -1128,12 +1106,9 @@ const result = await predicate(parameter); | ||
many(limit = Infinity, from = this.state.position) { | ||
if (this.finished) | ||
return Option.none; | ||
if (this.finished) return Option.none; | ||
const parameters = []; | ||
for (let i = from; i < this.length; ++i) { | ||
if (this.state.used.has(i)) | ||
continue; | ||
if (this.state.used.has(i)) continue; | ||
this.state.used.add(i); | ||
parameters.push(this.results.ordered[i]); | ||
if (parameters.length >= limit) | ||
break; | ||
if (parameters.length >= limit) break; | ||
} | ||
@@ -1143,8 +1118,6 @@ return parameters.length ? Option.some(parameters) : Option.none; | ||
filter(predicate, from = this.state.position) { | ||
if (this.finished) | ||
return Option.none; | ||
if (this.finished) return Option.none; | ||
const parameters = []; | ||
for (let i = from; i < this.length; ++i) { | ||
if (this.state.used.has(i)) | ||
continue; | ||
if (this.state.used.has(i)) continue; | ||
const parameter = this.results.ordered[i].value; | ||
@@ -1159,8 +1132,6 @@ if (predicate(parameter)) { | ||
async filterAsync(predicate, from = this.state.position) { | ||
if (this.finished) | ||
return Option.none; | ||
if (this.finished) return Option.none; | ||
const parameters = []; | ||
for (let i = from; i < this.length; ++i) { | ||
if (this.state.used.has(i)) | ||
continue; | ||
if (this.state.used.has(i)) continue; | ||
const parameter = this.results.ordered[i].value; | ||
@@ -1175,8 +1146,6 @@ if (await predicate(parameter)) { | ||
filterMap(predicate, from = this.state.position) { | ||
if (this.finished) | ||
return Option.none; | ||
if (this.finished) return Option.none; | ||
const parameters = []; | ||
for (let i = from; i < this.length; ++i) { | ||
if (this.state.used.has(i)) | ||
continue; | ||
if (this.state.used.has(i)) continue; | ||
const parameter = this.results.ordered[i].value; | ||
@@ -1192,8 +1161,6 @@ const result = predicate(parameter); | ||
async filterMapAsync(predicate, from = this.state.position) { | ||
if (this.finished) | ||
return Option.none; | ||
if (this.finished) return Option.none; | ||
const parameters = []; | ||
for (let i = from; i < this.length; ++i) { | ||
if (this.state.used.has(i)) | ||
continue; | ||
if (this.state.used.has(i)) continue; | ||
const parameter = this.results.ordered[i].value; | ||
@@ -1276,4 +1243,3 @@ const result = await predicate(parameter); | ||
const values = this.results.options.get(key); | ||
if (values) | ||
entries.push(...values); | ||
if (values) entries.push(...values); | ||
} | ||
@@ -1371,7 +1337,5 @@ return entries.length ? Option.some(entries) : Option.none; | ||
for (const [open, close] of this.quotes) { | ||
if (!this.input.startsWith(open, this.position)) | ||
continue; | ||
if (!this.input.startsWith(open, this.position)) continue; | ||
const end = this.input.indexOf(close, this.position + open.length); | ||
if (end === -1) | ||
continue; | ||
if (end === -1) continue; | ||
const value = this.input.slice(this.position + open.length, end); | ||
@@ -1460,6 +1424,4 @@ this.position = end + close.length; | ||
const existing = this.options.get(key); | ||
if (existing) | ||
existing.push(value); | ||
else | ||
this.options.set(key, [value]); | ||
if (existing) existing.push(value); | ||
else this.options.set(key, [value]); | ||
}).isSome(); | ||
@@ -1514,6 +1476,4 @@ } | ||
const prefix = this.prefixes.find((x) => input.startsWith(x)); | ||
if (!prefix) | ||
return Option.none; | ||
if (this.separators.some((x) => input.includes(x, prefix.length))) | ||
return Option.none; | ||
if (!prefix) return Option.none; | ||
if (this.separators.some((x) => input.includes(x, prefix.length))) return Option.none; | ||
return Option.some(input.slice(prefix.length)); | ||
@@ -1523,10 +1483,7 @@ } | ||
const prefix = this.prefixes.find((x) => input.startsWith(x)); | ||
if (!prefix) | ||
return Option.none; | ||
if (!prefix) return Option.none; | ||
for (const separator of this.separators) { | ||
const index = input.indexOf(separator, prefix.length + 1); | ||
if (index === -1) | ||
continue; | ||
if (index + separator.length === input.length) | ||
return Option.none; | ||
if (index === -1) continue; | ||
if (index + separator.length === input.length) return Option.none; | ||
const key = input.slice(prefix.length, index); | ||
@@ -1544,6 +1501,4 @@ const value = input.slice(index + separator.length); | ||
function join(parameters) { | ||
if (parameters.length === 0) | ||
return ""; | ||
if (parameters.length === 1) | ||
return parameters[0].value; | ||
if (parameters.length === 0) return ""; | ||
if (parameters.length === 1) return parameters[0].value; | ||
let output = parameters[0].value; | ||
@@ -1558,6 +1513,4 @@ for (let i = 1; i < parameters.length; i++) { | ||
function joinRaw(parameters) { | ||
if (parameters.length === 0) | ||
return ""; | ||
if (parameters.length === 1) | ||
return parameters[0].raw; | ||
if (parameters.length === 0) return ""; | ||
if (parameters.length === 1) return parameters[0].raw; | ||
let output = parameters[0].raw; | ||
@@ -1590,3 +1543,3 @@ for (let i = 1; i < parameters.length; i++) { | ||
})({}); | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=index.global.js.map | ||
//# sourceMappingURL=index.global.js.map |
{ | ||
"name": "@sapphire/lexure", | ||
"version": "1.1.8-next.5873dace.0", | ||
"version": "1.1.8-next.5ac3f246", | ||
"description": "Parser and utilities for non-technical user input", | ||
@@ -28,8 +28,9 @@ "author": "@sapphire", | ||
"lint": "eslint src tests --ext ts --fix -c ../../.eslintrc", | ||
"build": "tsup && yarn build:rename-cjs-index", | ||
"build:rename-cjs-index": "tsx --tsconfig ../../scripts/tsconfig.json ../../scripts/rename-cjs-index.cts", | ||
"build": "yarn gen-index && tsup && yarn build:rename-cjs-index", | ||
"build:rename-cjs-index": "tsx ../../scripts/rename-cjs-index.cts", | ||
"docs": "typedoc-json-parser", | ||
"prepack": "yarn build", | ||
"bump": "cliff-jumper", | ||
"check-update": "cliff-jumper --dry-run" | ||
"check-update": "cliff-jumper --dry-run", | ||
"gen-index": "tsx ../../scripts/gen-index.cts lexure --write" | ||
}, | ||
@@ -70,11 +71,11 @@ "repository": { | ||
"devDependencies": { | ||
"@favware/cliff-jumper": "^3.0.3", | ||
"@vitest/coverage-v8": "^1.5.2", | ||
"tsup": "^8.0.2", | ||
"tsx": "^4.7.3", | ||
"@favware/cliff-jumper": "^5.0.0", | ||
"@vitest/coverage-v8": "^2.1.3", | ||
"tsup": "^8.3.0", | ||
"tsx": "^4.19.1", | ||
"typedoc": "^0.25.13", | ||
"typedoc-json-parser": "^9.0.1", | ||
"typescript": "^5.4.5", | ||
"vitest": "^1.5.2" | ||
"typedoc-json-parser": "^10.0.0", | ||
"typescript": "~5.4.5", | ||
"vitest": "^2.1.3" | ||
} | ||
} |
@@ -10,3 +10,2 @@ <div align="center"> | ||
[](https://github.com/sapphiredev/utilities/blob/main/LICENSE.md) | ||
[](https://codecov.io/gh/sapphiredev/utilities) | ||
[](https://bundlephobia.com/lexure?p=@sapphire/lexure) | ||
@@ -13,0 +12,0 @@ [](https://www.npmjs.com/package/@sapphire/lexure) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
362127
3167
91