UNPKG

@extra-array/prefixes

Version:
11 lines (10 loc) 220 B
'use strict'; function* prefixes(x, n = -1) { if (n >= 0) { yield x.slice(0, n); return; } for (var i = 0, I = x.length; i <= I; i++) yield x.slice(0, i); } module.exports = prefixes;