• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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}
24