Sha256: 09f1e5ab56a90f1cafc4d37d8ec9c0901b2ac4000175b0f68d7289f5f42e0d65
Contents?: true
Size: 664 Bytes
Versions: 59
Compression:
Stored size: 664 Bytes
Contents
'use strict'; var toRegex = require('to-regex'); var regexNot = require('regex-not'); var cached; /** * Get the last element from `array` * @param {Array} `array` * @return {*} */ exports.last = function(arr) { return arr[arr.length - 1]; }; /** * Create and cache regex to use for text nodes */ exports.createRegex = function(pattern, include) { if (cached) return cached; var opts = {contains: true, strictClose: false}; var not = regexNot.create(pattern, opts); var re; if (typeof include === 'string') { re = toRegex('^(?:' + include + '|' + not + ')', opts); } else { re = toRegex(not, opts); } return (cached = re); };
Version data entries
59 entries across 38 versions & 12 rubygems