UNPKG

atriusmaps-node-sdk

Version:

This project provides an API to Atrius Personal Wayfinder maps within a Node environment. See the README.md for more information

38 lines (31 loc) 1.07 kB
'use strict'; var lang = require('./lang.js'); /* eslint-disable camelcase */ const // regex_whitespace = /\W+/, // regex_strip = regex("[^a-z0-9 ]"), regex_a = lang.regex('[àáâãäå]'); const regex_e = lang.regex('[èéêë]'); const regex_i = lang.regex('[ìíîï]'); const regex_o = lang.regex('[òóôõöő]'); const regex_u = lang.regex('[ùúûüű]'); const regex_y = lang.regex('[ýŷÿ]'); const regex_n = lang.regex('ñ'); const regex_c = lang.regex('[çc]'); const regex_s = lang.regex('ß'); const regex_and = lang.regex(' & '); const pairs = [regex_a, 'a', regex_e, 'e', regex_i, 'i', regex_o, 'o', regex_u, 'u', regex_y, 'y', regex_n, 'n', regex_c, 'k', regex_s, 's', regex_and, ' and ' // regex_whitespace, " " // regex_strip, "" ]; /** * @param {string|number} str * @this IndexInterface */ function encode (str) { str = '' + str; return lang.pipeline.call(this, /* string: */lang.normalize(str).toLowerCase(), /* normalize: */!str.normalize && pairs, /* split: */lang.regex_whitespace, false) } exports.encode = encode;