Comparing version 2.0.0 to 2.0.1
@@ -1,13 +0,8 @@ | ||
/** | ||
* Quote a value. | ||
* | ||
* @param {string | string[]} value Value(s) to wrap in quotes | ||
* @param {string} [open='"'] Opening quote | ||
* @param {string} [close=open] Closing quote | ||
* @returns {string | string[]} | ||
*/ | ||
export function quotation( | ||
value: string | string[], | ||
open?: string, | ||
close?: string | ||
): string | string[] | ||
/** @type {{ | ||
* (value: string, open?: string, close?: string): string | ||
* (value: string[], open?: string, close?: string): string[] | ||
* }} */ | ||
export var quotation: { | ||
(value: string, open?: string, close?: string): string | ||
(value: string[], open?: string, close?: string): string[] | ||
} |
55
index.js
@@ -1,29 +0,36 @@ | ||
/** | ||
* Quote a value. | ||
* | ||
* @param {string | string[]} value Value(s) to wrap in quotes | ||
* @param {string} [open='"'] Opening quote | ||
* @param {string} [close=open] Closing quote | ||
* @returns {string | string[]} | ||
*/ | ||
export function quotation(value, open, close) { | ||
var start = open || '"' | ||
var end = close || start | ||
/** @type {string[]} */ | ||
var result = [] | ||
var index = -1 | ||
// prettier-ignore | ||
/** @type {{ | ||
* (value: string, open?: string, close?: string): string | ||
* (value: string[], open?: string, close?: string): string[] | ||
* }} */ | ||
export var quotation = ( | ||
/** | ||
* Quote a value. | ||
* | ||
* @param {string | string[]} value Value(s) to wrap in quotes | ||
* @param {string} [open='"'] Opening quote | ||
* @param {string} [close=open] Closing quote | ||
* @returns {string | string[]} | ||
*/ | ||
function (value, open, close) { | ||
var start = open || '"' | ||
var end = close || start | ||
/** @type {string[]} */ | ||
var result = [] | ||
var index = -1 | ||
if (Array.isArray(value)) { | ||
while (++index < value.length) { | ||
result[index] = start + value[index] + end | ||
if (Array.isArray(value)) { | ||
while (++index < value.length) { | ||
result[index] = start + value[index] + end | ||
} | ||
return result | ||
} | ||
return result | ||
} | ||
if (typeof value === 'string') { | ||
return start + value + end | ||
} | ||
if (typeof value === 'string') { | ||
return start + value + end | ||
throw new TypeError('Expected string or array of strings') | ||
} | ||
throw new TypeError('Expected string or array of strings') | ||
} | ||
) |
{ | ||
"name": "quotation", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Quote a value", | ||
@@ -68,2 +68,3 @@ "license": "MIT", | ||
"rules": { | ||
"import/no-mutable-exports": "off", | ||
"no-var": "off", | ||
@@ -70,0 +71,0 @@ "prefer-arrow-callback": "off" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5892
40