|
1 |
| -import { memoize, without, range } from 'ramda' |
| 1 | +import { memoizeWith, identity, without, range } from 'ramda' |
2 | 2 |
|
3 | 3 | // IMAP Formal Syntax
|
4 | 4 | // http://tools.ietf.org/html/rfc3501#section-9
|
5 | 5 |
|
6 | 6 | const expandRange = (start, end) => String.fromCharCode.apply(String, range(start, end + 1))
|
7 | 7 | const excludeChars = (source, exclude) => without(exclude.split(''), source.split('')).join('')
|
8 | 8 |
|
9 |
| -export const CHAR = memoize(() => expandRange(0x01, 0x7F)) |
10 |
| -export const CHAR8 = memoize(() => expandRange(0x01, 0xFF)) |
| 9 | +export const CHAR = memoizeWith(identity, () => expandRange(0x01, 0x7F)) |
| 10 | +export const CHAR8 = memoizeWith(identity, () => expandRange(0x01, 0xFF)) |
11 | 11 | export const SP = () => ' '
|
12 |
| -export const CTL = memoize(() => expandRange(0x00, 0x1F) + '\x7F') |
| 12 | +export const CTL = memoizeWith(identity, () => expandRange(0x00, 0x1F) + '\x7F') |
13 | 13 | export const DQUOTE = () => '"'
|
14 |
| -export const ALPHA = memoize(() => expandRange(0x41, 0x5A) + expandRange(0x61, 0x7A)) |
15 |
| -export const DIGIT = memoize(() => expandRange(0x30, 0x39) + expandRange(0x61, 0x7A)) |
16 |
| -export const ATOM_CHAR = memoize(() => excludeChars(CHAR(), ATOM_SPECIALS())) |
17 |
| -export const ASTRING_CHAR = memoize(() => ATOM_CHAR() + RESP_SPECIALS()) |
18 |
| -export const TEXT_CHAR = memoize(() => excludeChars(CHAR(), '\r\n')) |
19 |
| -export const ATOM_SPECIALS = memoize(() => '(' + ')' + '{' + SP() + CTL() + LIST_WILDCARDS() + QUOTED_SPECIALS() + RESP_SPECIALS()) |
| 14 | +export const ALPHA = memoizeWith(identity, () => expandRange(0x41, 0x5A) + expandRange(0x61, 0x7A)) |
| 15 | +export const DIGIT = memoizeWith(identity, () => expandRange(0x30, 0x39) + expandRange(0x61, 0x7A)) |
| 16 | +export const ATOM_CHAR = memoizeWith(identity, () => excludeChars(CHAR(), ATOM_SPECIALS())) |
| 17 | +export const ASTRING_CHAR = memoizeWith(identity, () => ATOM_CHAR() + RESP_SPECIALS()) |
| 18 | +export const TEXT_CHAR = memoizeWith(identity, () => excludeChars(CHAR(), '\r\n')) |
| 19 | +export const ATOM_SPECIALS = memoizeWith(identity, () => '(' + ')' + '{' + SP() + CTL() + LIST_WILDCARDS() + QUOTED_SPECIALS() + RESP_SPECIALS()) |
20 | 20 | export const LIST_WILDCARDS = () => '%' + '*'
|
21 |
| -export const QUOTED_SPECIALS = memoize(() => DQUOTE() + '\\') |
| 21 | +export const QUOTED_SPECIALS = memoizeWith(identity, () => DQUOTE() + '\\') |
22 | 22 | export const RESP_SPECIALS = () => ']'
|
23 |
| -export const TAG = memoize(() => excludeChars(ASTRING_CHAR(), '+')) |
24 |
| -export const COMMAND = memoize(() => ALPHA() + DIGIT()) |
| 23 | +export const TAG = memoizeWith(identity, () => excludeChars(ASTRING_CHAR(), '+')) |
| 24 | +export const COMMAND = memoizeWith(identity, () => ALPHA() + DIGIT()) |
25 | 25 | export const verify = function (str, allowedChars) {
|
26 | 26 | for (var i = 0, len = str.length; i < len; i++) {
|
27 | 27 | if (allowedChars.indexOf(str.charAt(i)) < 0) {
|
|
0 commit comments