mirror of
https://github.com/x1xhlol/system-prompts-and-models-of-ai-tools.git
synced 2026-02-04 05:50:50 +00:00
nhj
more
This commit is contained in:
65
unified-ai-platform/node_modules/yn/index.d.ts
generated
vendored
Normal file
65
unified-ai-platform/node_modules/yn/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
declare namespace yn {
|
||||
interface Options {
|
||||
/**
|
||||
Use a key distance-based score to leniently accept typos of `yes` and `no`.
|
||||
|
||||
@default false
|
||||
*/
|
||||
readonly lenient?: boolean;
|
||||
|
||||
/**
|
||||
Default value if no match was found.
|
||||
|
||||
@default null
|
||||
*/
|
||||
readonly default?: boolean | null;
|
||||
}
|
||||
|
||||
interface OptionsWithDefault extends Options {
|
||||
default: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
declare const yn: {
|
||||
/**
|
||||
Parse yes/no like values.
|
||||
|
||||
The following case-insensitive values are recognized: `'y', 'yes', 'true', true, '1', 1, 'n', 'no', 'false', false, '0', 0`
|
||||
|
||||
@param input - Value that should be converted.
|
||||
@returns The parsed input if it can be parsed or the default value defined in the `default` option.
|
||||
|
||||
@example
|
||||
```
|
||||
import yn = require('yn');
|
||||
|
||||
yn('y');
|
||||
//=> true
|
||||
|
||||
yn('NO');
|
||||
//=> false
|
||||
|
||||
yn(true);
|
||||
//=> true
|
||||
|
||||
yn('abomasum');
|
||||
//=> null
|
||||
|
||||
yn('abomasum', {default: false});
|
||||
//=> false
|
||||
|
||||
yn('mo', {lenient: true});
|
||||
//=> false
|
||||
```
|
||||
*/
|
||||
(input: unknown, options: yn.OptionsWithDefault): boolean;
|
||||
(input: unknown, options?: yn.Options): boolean | null;
|
||||
|
||||
// TODO: Remove this for the next major release, refactor the whole definition to:
|
||||
// declare function yn(input: unknown, options: yn.OptionsWithDefault): boolean;
|
||||
// declare function yn(input: unknown, options?: yn.Options): boolean | null;
|
||||
// export = yn;
|
||||
default: typeof yn;
|
||||
};
|
||||
|
||||
export = yn;
|
||||
33
unified-ai-platform/node_modules/yn/index.js
generated
vendored
Normal file
33
unified-ai-platform/node_modules/yn/index.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
'use strict';
|
||||
const lenient = require('./lenient');
|
||||
|
||||
const yn = (input, options) => {
|
||||
input = String(input).trim();
|
||||
|
||||
options = Object.assign({
|
||||
lenient: false,
|
||||
default: null
|
||||
}, options);
|
||||
|
||||
if (options.default !== null && typeof options.default !== 'boolean') {
|
||||
throw new TypeError(`Expected the \`default\` option to be of type \`boolean\`, got \`${typeof options.default}\``);
|
||||
}
|
||||
|
||||
if (/^(?:y|yes|true|1)$/i.test(input)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (/^(?:n|no|false|0)$/i.test(input)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (options.lenient === true) {
|
||||
return lenient(input, options);
|
||||
}
|
||||
|
||||
return options.default;
|
||||
};
|
||||
|
||||
module.exports = yn;
|
||||
// TODO: Remove this for the next major release
|
||||
module.exports.default = yn;
|
||||
105
unified-ai-platform/node_modules/yn/lenient.js
generated
vendored
Normal file
105
unified-ai-platform/node_modules/yn/lenient.js
generated
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
'use strict';
|
||||
|
||||
const YES_MATCH_SCORE_THRESHOLD = 2;
|
||||
const NO_MATCH_SCORE_THRESHOLD = 1.25;
|
||||
|
||||
const yMatch = new Map([
|
||||
[5, 0.25],
|
||||
[6, 0.25],
|
||||
[7, 0.25],
|
||||
['t', 0.75],
|
||||
['y', 1],
|
||||
['u', 0.75],
|
||||
['g', 0.25],
|
||||
['h', 0.25],
|
||||
['j', 0.25]
|
||||
]);
|
||||
|
||||
const eMatch = new Map([
|
||||
[2, 0.25],
|
||||
[3, 0.25],
|
||||
[4, 0.25],
|
||||
['w', 0.75],
|
||||
['e', 1],
|
||||
['r', 0.75],
|
||||
['s', 0.25],
|
||||
['d', 0.25],
|
||||
['f', 0.25]
|
||||
]);
|
||||
|
||||
const sMatch = new Map([
|
||||
['q', 0.25],
|
||||
['w', 0.25],
|
||||
['e', 0.25],
|
||||
['a', 0.75],
|
||||
['s', 1],
|
||||
['d', 0.75],
|
||||
['z', 0.25],
|
||||
['x', 0.25],
|
||||
['c', 0.25]
|
||||
]);
|
||||
|
||||
const nMatch = new Map([
|
||||
['h', 0.25],
|
||||
['j', 0.25],
|
||||
['k', 0.25],
|
||||
['b', 0.75],
|
||||
['n', 1],
|
||||
['m', 0.75]
|
||||
]);
|
||||
|
||||
const oMatch = new Map([
|
||||
[9, 0.25],
|
||||
[0, 0.25],
|
||||
['i', 0.75],
|
||||
['o', 1],
|
||||
['p', 0.75],
|
||||
['k', 0.25],
|
||||
['l', 0.25]
|
||||
]);
|
||||
|
||||
function getYesMatchScore(value) {
|
||||
const [y, e, s] = value;
|
||||
let score = 0;
|
||||
|
||||
if (yMatch.has(y)) {
|
||||
score += yMatch.get(y);
|
||||
}
|
||||
|
||||
if (eMatch.has(e)) {
|
||||
score += eMatch.get(e);
|
||||
}
|
||||
|
||||
if (sMatch.has(s)) {
|
||||
score += sMatch.get(s);
|
||||
}
|
||||
|
||||
return score;
|
||||
}
|
||||
|
||||
function getNoMatchScore(value) {
|
||||
const [n, o] = value;
|
||||
let score = 0;
|
||||
|
||||
if (nMatch.has(n)) {
|
||||
score += nMatch.get(n);
|
||||
}
|
||||
|
||||
if (oMatch.has(o)) {
|
||||
score += oMatch.get(o);
|
||||
}
|
||||
|
||||
return score;
|
||||
}
|
||||
|
||||
module.exports = (input, options) => {
|
||||
if (getYesMatchScore(input) >= YES_MATCH_SCORE_THRESHOLD) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (getNoMatchScore(input) >= NO_MATCH_SCORE_THRESHOLD) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return options.default;
|
||||
};
|
||||
42
unified-ai-platform/node_modules/yn/package.json
generated
vendored
Normal file
42
unified-ai-platform/node_modules/yn/package.json
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "yn",
|
||||
"version": "3.1.1",
|
||||
"description": "Parse yes/no like values",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/yn",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"lenient.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"yn",
|
||||
"yes",
|
||||
"no",
|
||||
"cli",
|
||||
"prompt",
|
||||
"validate",
|
||||
"input",
|
||||
"answer",
|
||||
"true",
|
||||
"false",
|
||||
"parse",
|
||||
"lenient"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^1.4.1",
|
||||
"tsd": "^0.7.2",
|
||||
"xo": "^0.24.0"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user