@beenotung/tslib
Version:
utils library in Typescript
27 lines (26 loc) • 731 B
JavaScript
;
/**
* @description this module is for better performance by reducing the need to invoke string.substring() and array.slice()
* */
Object.defineProperty(exports, "__esModule", { value: true });
exports.wrappedLast = exports.pop = exports.wrapArray = exports.wrapString = void 0;
const wrapString = (s) => ({
s,
offset: 0,
length: s.length,
});
exports.wrapString = wrapString;
const wrapArray = (s) => ({
s,
offset: 0,
length: s.length,
});
exports.wrapArray = wrapArray;
const pop = (x) => ({
s: x.s,
offset: x.offset,
length: x.length - 1 < 0 ? 0 : x.length - 1,
});
exports.pop = pop;
const wrappedLast = (x) => x.s[x.offset + x.length - 1];
exports.wrappedLast = wrappedLast;