Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | 22x 22x 4267x 22x 4265x 4263x 2x 22x 4264x 4263x 1x 22x 4264x 4264x 4264x | /* eslint-disable @typescript-eslint/ban-types */
import isString from './is-string.js'
const quoted =
(value: string | String): string =>
'N\'' + (value.indexOf('\'') !== -1 ? value.replace(/'/g, '\'\'') : value) + '\''
const quotedLf =
(value: string | String): string => {
if (value.indexOf('\n') === -1) {
return quoted(value)
}
return 'concat_ws(nchar(10), ' + value.split('\n').map(quoted).join(', ') + ')'
}
const quotedCrLf =
(value: string | String): string => {
if (value.indexOf('\r\n') === -1) {
return quotedLf(value)
}
return 'concat_ws(nchar(13) + nchar(10), ' + value.split('\r\n').map(quotedLf).join(', ') + ')'
}
export const quotedNstring =
(value: string | String): string => {
Iif (!isString(value)) {
throw new TypeError(`Expected string while trying to quote, got ${value}.`)
}
return quotedCrLf(value)
}
export default quotedNstring
|