source: trip-planner-front/node_modules/tar/lib/winchars.js@ 188ee53

Last change on this file since 188ee53 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 535 bytes
Line 
1'use strict'
2
3// When writing files on Windows, translate the characters to their
4// 0xf000 higher-encoded versions.
5
6const raw = [
7 '|',
8 '<',
9 '>',
10 '?',
11 ':',
12]
13
14const win = raw.map(char =>
15 String.fromCharCode(0xf000 + char.charCodeAt(0)))
16
17const toWin = new Map(raw.map((char, i) => [char, win[i]]))
18const toRaw = new Map(win.map((char, i) => [char, raw[i]]))
19
20module.exports = {
21 encode: s => raw.reduce((s, c) => s.split(c).join(toWin.get(c)), s),
22 decode: s => win.reduce((s, c) => s.split(c).join(toRaw.get(c)), s),
23}
Note: See TracBrowser for help on using the repository browser.