UNPKG

is-newline

Version:

Determine whether a given string is a newline character.

13 lines (9 loc) 282 B
'use strict' var newlineRegex = require('newline-regex') module.exports = function isNewline (str) { if (typeof str !== 'string') { throw new TypeError('is-newline expected a string') } var regex = new RegExp('^' + newlineRegex.source + '$') return regex.test(str) }