UNPKG

esm-require-directory

Version:

require a directory of modules using es6 modules require

11 lines (10 loc) 469 B
/** * String.prototype.endsWith wrapper for Node.js 0.8+ * - Uses native endsWith on Node 4.0+ / ES2015+ * - Falls back to lastIndexOf on Node 0.8-3.x */ const hasEndsWith = typeof String.prototype.endsWith === 'function'; export function stringEndsWith(str, search, position) { if (hasEndsWith) return str.endsWith(search, position); const len = position === undefined ? str.length : position; return str.lastIndexOf(search) === len - search.length; }