Socket
Socket
Sign inDemoInstall

yn

Package Overview
Dependencies
0
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.0.0 to 5.0.0

40

index.d.ts

@@ -1,21 +0,19 @@

declare namespace yn {
interface Options {
/**
Use a key distance-based score to leniently accept typos of `yes` and `no`.
export interface Options {
/**
Use a key distance-based score to leniently accept typos of `yes` and `no`.
@default false
*/
readonly lenient?: boolean;
@default false
*/
readonly lenient?: boolean;
/**
Default value if no match was found.
/**
The default value if no match was found.
@default undefined
*/
readonly default?: boolean | undefined;
}
@default undefined
*/
readonly default?: boolean | undefined;
}
interface OptionsWithDefault extends Options {
default: boolean;
}
export interface OptionsWithDefault extends Options {
readonly default: boolean;
}

@@ -28,3 +26,3 @@

@param input - Value that should be converted.
@param input - The value that should be converted.
@returns The parsed input if it can be parsed or the default value defined in the `default` option.

@@ -34,3 +32,3 @@

```
import yn = require('yn');
import yn from 'yn';

@@ -56,5 +54,3 @@ yn('y');

*/
declare function yn(input: unknown, options: yn.OptionsWithDefault): boolean;
declare function yn(input: unknown, options?: yn.Options): boolean | undefined;
export = yn;
export default function yn(input: unknown, options: OptionsWithDefault): boolean;
export default function yn(input: unknown, options?: Options): boolean | undefined;

@@ -1,8 +0,7 @@

'use strict';
const lenientFunction = require('./lenient');
import lenientFunction from './lenient.js';
const yn = (value, {
export default function yn(value, {
lenient = false,
default: default_
} = {}) => {
default: default_,
} = {}) {
value = String(value).trim();

@@ -27,4 +26,2 @@

return default_;
};
module.exports = yn;
}

@@ -1,3 +0,1 @@

'use strict';
const YES_MATCH_SCORE_THRESHOLD = 2;

@@ -15,5 +13,6 @@ const NO_MATCH_SCORE_THRESHOLD = 1.25;

['h', 0.25],
['j', 0.25]
['j', 0.25],
]);
// eslint-disable-next-line unicorn/prevent-abbreviations
const eMatch = new Map([

@@ -28,3 +27,3 @@ [2, 0.25],

['d', 0.25],
['f', 0.25]
['f', 0.25],
]);

@@ -41,3 +40,3 @@

['x', 0.25],
['c', 0.25]
['c', 0.25],
]);

@@ -51,3 +50,3 @@

['n', 1],
['m', 0.75]
['m', 0.75],
]);

@@ -62,6 +61,7 @@

['k', 0.25],
['l', 0.25]
['l', 0.25],
]);
function getYesMatchScore(value) {
// eslint-disable-next-line unicorn/prevent-abbreviations
const [y, e, s] = value;

@@ -100,3 +100,3 @@ let score = 0;

module.exports = (input, default_) => {
export default function lenient(input, default_) {
if (getYesMatchScore(input) >= YES_MATCH_SCORE_THRESHOLD) {

@@ -111,2 +111,2 @@ return true;

return default_;
};
}
{
"name": "yn",
"version": "4.0.0",
"version": "5.0.0",
"description": "Parse yes/no like values",
"license": "MIT",
"repository": "sindresorhus/yn",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": "./index.js",
"engines": {
"node": ">=10"
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},

@@ -38,6 +41,6 @@ "scripts": {

"devDependencies": {
"ava": "^2.4.0",
"tsd": "^0.11.0",
"xo": "^0.25.3"
"ava": "^3.15.0",
"tsd": "^0.17.0",
"xo": "^0.44.0"
}
}

@@ -1,2 +0,2 @@

# yn [![Build Status](https://travis-ci.org/sindresorhus/yn.svg?branch=master)](https://travis-ci.org/sindresorhus/yn)
# yn

@@ -17,3 +17,2 @@ > Parse yes/no like values

## Install

@@ -25,7 +24,6 @@

## Usage
```js
const yn = require('yn');
import yn from 'yn';

@@ -53,3 +51,2 @@ yn('y');

## API

@@ -63,3 +60,3 @@

Value that should be converted.
The value that should be converted.

@@ -82,2 +79,2 @@ #### options

Default value if no match was found.
The default value if no match was found.

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc