UNPKG

ascii-chr

Version:
35 lines (29 loc) 556 B
'use strict'; const charCode = require('./charCode'); const makeCharCodes = (n = 257) => { const chr = new Array(n); // 1 byte while (n > 0) { chr[n -= 1] = charCode(n & 0xff); } return chr; }; const makeCharCodes2 = (n = 2048) => { const chr = new Array(n); chr[n] = '\x00'; // 2 bytes while (n > 0x80) { chr[n -= 1] = charCode( 0xc0 | n >> 6 & 0x1f, 0x80 | n & 0x3f); } // 1 byte while (n > 0) { chr[n -= 1] = charCode(n); } return chr; }; module.exports = { makeCharCodes, makeCharCodes2, };