aboutsummaryrefslogtreecommitdiffstats
path: root/node_modules/abbrev
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/abbrev')
-rw-r--r--node_modules/abbrev/LICENSE46
-rw-r--r--node_modules/abbrev/README.md23
-rw-r--r--node_modules/abbrev/lib/index.js53
-rw-r--r--node_modules/abbrev/package.json41
4 files changed, 163 insertions, 0 deletions
diff --git a/node_modules/abbrev/LICENSE b/node_modules/abbrev/LICENSE
new file mode 100644
index 0000000..9bcfa9d
--- /dev/null
+++ b/node_modules/abbrev/LICENSE
@@ -0,0 +1,46 @@
+This software is dual-licensed under the ISC and MIT licenses.
+You may use this software under EITHER of the following licenses.
+
+----------
+
+The ISC License
+
+Copyright (c) Isaac Z. Schlueter and Contributors
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+----------
+
+Copyright Isaac Z. Schlueter and Contributors
+All rights reserved.
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
diff --git a/node_modules/abbrev/README.md b/node_modules/abbrev/README.md
new file mode 100644
index 0000000..99746fe
--- /dev/null
+++ b/node_modules/abbrev/README.md
@@ -0,0 +1,23 @@
+# abbrev-js
+
+Just like [ruby's Abbrev](http://apidock.com/ruby/Abbrev).
+
+Usage:
+
+ var abbrev = require("abbrev");
+ abbrev("foo", "fool", "folding", "flop");
+
+ // returns:
+ { fl: 'flop'
+ , flo: 'flop'
+ , flop: 'flop'
+ , fol: 'folding'
+ , fold: 'folding'
+ , foldi: 'folding'
+ , foldin: 'folding'
+ , folding: 'folding'
+ , foo: 'foo'
+ , fool: 'fool'
+ }
+
+This is handy for command-line scripts, or other cases where you want to be able to accept shorthands.
diff --git a/node_modules/abbrev/lib/index.js b/node_modules/abbrev/lib/index.js
new file mode 100644
index 0000000..f7bee0c
--- /dev/null
+++ b/node_modules/abbrev/lib/index.js
@@ -0,0 +1,53 @@
+module.exports = abbrev
+
+function abbrev (...args) {
+ let list = args
+ if (args.length === 1 && (Array.isArray(args[0]) || typeof args[0] === 'string')) {
+ list = [].concat(args[0])
+ }
+
+ for (let i = 0, l = list.length; i < l; i++) {
+ list[i] = typeof list[i] === 'string' ? list[i] : String(list[i])
+ }
+
+ // sort them lexicographically, so that they're next to their nearest kin
+ list = list.sort(lexSort)
+
+ // walk through each, seeing how much it has in common with the next and previous
+ const abbrevs = {}
+ let prev = ''
+ for (let ii = 0, ll = list.length; ii < ll; ii++) {
+ const current = list[ii]
+ const next = list[ii + 1] || ''
+ let nextMatches = true
+ let prevMatches = true
+ if (current === next) {
+ continue
+ }
+ let j = 0
+ const cl = current.length
+ for (; j < cl; j++) {
+ const curChar = current.charAt(j)
+ nextMatches = nextMatches && curChar === next.charAt(j)
+ prevMatches = prevMatches && curChar === prev.charAt(j)
+ if (!nextMatches && !prevMatches) {
+ j++
+ break
+ }
+ }
+ prev = current
+ if (j === cl) {
+ abbrevs[current] = current
+ continue
+ }
+ for (let a = current.slice(0, j); j <= cl; j++) {
+ abbrevs[a] = current
+ a += current.charAt(j)
+ }
+ }
+ return abbrevs
+}
+
+function lexSort (a, b) {
+ return a === b ? 0 : a > b ? 1 : -1
+}
diff --git a/node_modules/abbrev/package.json b/node_modules/abbrev/package.json
new file mode 100644
index 0000000..f17aacc
--- /dev/null
+++ b/node_modules/abbrev/package.json
@@ -0,0 +1,41 @@
+{
+ "name": "abbrev",
+ "version": "4.0.0",
+ "description": "Like ruby's abbrev module, but in js",
+ "author": "GitHub Inc.",
+ "main": "lib/index.js",
+ "scripts": {
+ "test": "node --test",
+ "lint": "npm run eslint",
+ "postlint": "template-oss-check",
+ "template-oss-apply": "template-oss-apply --force",
+ "lintfix": "npm run eslint -- --fix",
+ "snap": "node --test --test-update-snapshots",
+ "posttest": "npm run lint",
+ "eslint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"",
+ "test:cover": "node --test --experimental-test-coverage --test-timeout=3000 --test-coverage-lines=100 --test-coverage-functions=100 --test-coverage-branches=100"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/npm/abbrev-js.git"
+ },
+ "license": "ISC",
+ "devDependencies": {
+ "@npmcli/eslint-config": "^5.0.0",
+ "@npmcli/template-oss": "4.26.1"
+ },
+ "files": [
+ "bin/",
+ "lib/"
+ ],
+ "engines": {
+ "node": "^20.17.0 || >=22.9.0"
+ },
+ "templateOSS": {
+ "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
+ "version": "4.26.1",
+ "publish": true,
+ "testRunner": "node:test",
+ "latestCiVersion": 24
+ }
+}