All files / src decode.js

100% Statements 1/1
100% Branches 0/0
100% Functions 0/0
100% Lines 1/1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24        1x                                      
import {join, filter, pipe, map} from 'f-utility'
import {EMPTY} from '@constants/empty'
import {parseBinaryCharCode, alterRange, charCodeAt, magicRange, match} from '@fn/index'
 
const joinNothing = join(EMPTY)
 
/**
 * convert a string from a zero-width representation
 * @method decode
 * @param {string} payload - a payload to decode
 * @returns {string} decoded string
 * @public
 */
export const decode = pipe(
  Array.from,
  map(charCodeAt),
  filter(magicRange),
  map(alterRange),
  joinNothing,
  match,
  map(parseBinaryCharCode),
  joinNothing
)