Last change
on this file since b738035 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 |
|
---|
6 | const raw = [
|
---|
7 | '|',
|
---|
8 | '<',
|
---|
9 | '>',
|
---|
10 | '?',
|
---|
11 | ':',
|
---|
12 | ]
|
---|
13 |
|
---|
14 | const win = raw.map(char =>
|
---|
15 | String.fromCharCode(0xf000 + char.charCodeAt(0)))
|
---|
16 |
|
---|
17 | const toWin = new Map(raw.map((char, i) => [char, win[i]]))
|
---|
18 | const toRaw = new Map(win.map((char, i) => [char, raw[i]]))
|
---|
19 |
|
---|
20 | module.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.