Skip to content

Commit 0f91aaa

Browse files
committed
arrow functions
1 parent a7ba01a commit 0f91aaa

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

lib/diacritics.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
type TDiacraticList = {[key:string]:string};
33

44
// https://github.com/andrewrk/node-diacritics/blob/master/index.js
5-
var DIACRITICS:TDiacraticList = {
5+
export const DIACRITICS:TDiacraticList = {
66
" ":" ",
77
0:"߀",
88
A:"ⒶAÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢÅǺǍȀȂẠẬẶḀĄȺⱯ",
@@ -138,7 +138,7 @@ var code_points = [
138138
* via https://github.com/krisk/Fuse/issues/133#issuecomment-318692703
139139
*
140140
*/
141-
export function asciifold(str:string):string{
141+
export const asciifold = (str:string):string => {
142142
return str.normalize('NFD').replace(/[\u0300-\u036F]/g, '').normalize('NFKD').toLowerCase();
143143
};
144144

@@ -188,7 +188,7 @@ function toCodePoints(tolerance=8){
188188
* Generate a list of diacritics from the list of code points
189189
*
190190
*/
191-
export function generateDiacritics():TDiacraticList{
191+
export const generateDiacritics = ():TDiacraticList => {
192192

193193
var latin_convert:{[key:string]:string} = {
194194
'l·': 'l',
@@ -236,7 +236,7 @@ export function generateDiacritics():TDiacraticList{
236236
*
237237
*/
238238
var diacritics:null|TDiacraticList = null
239-
export function diacriticRegexPoints(regex:string):string{
239+
export const diacriticRegexPoints = (regex:string):string => {
240240

241241
if( diacritics === null ){
242242
diacritics = generateDiacritics();

lib/utils.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import * as T from './types.ts';
1212
* @param {String} name The optionally dotted property name to fetch
1313
* @return {Object} The resolved property value
1414
*/
15-
export function getAttr(obj:{[key:string]:any}, name:string ) {
15+
export const getAttr = (obj:{[key:string]:any}, name:string ) => {
1616
if (!obj ) return;
1717
return obj[name];
1818
};
@@ -23,7 +23,7 @@ export function getAttr(obj:{[key:string]:any}, name:string ) {
2323
* @param {String} name The optionally dotted property name to fetch
2424
* @return {Object} The resolved property value
2525
*/
26-
export function getAttrNesting(obj:{[key:string]:any}, name:string ) {
26+
export const getAttrNesting = (obj:{[key:string]:any}, name:string ) => {
2727
if (!obj ) return;
2828
var part, names = name.split(".");
2929
while( (part = names.shift()) && (obj = obj[part]));
@@ -35,7 +35,7 @@ export function getAttrNesting(obj:{[key:string]:any}, name:string ) {
3535
* given value is against a search token.
3636
*
3737
*/
38-
export function scoreValue(value:string, token:T.Token, weight:number ):number {
38+
export const scoreValue = (value:string, token:T.Token, weight:number ):number => {
3939
var score, pos;
4040

4141
if (!value) return 0;
@@ -50,7 +50,7 @@ export function scoreValue(value:string, token:T.Token, weight:number ):number {
5050
return score * weight;
5151
};
5252

53-
export function escape_regex(str:string):string {
53+
export const escape_regex = (str:string):string => {
5454
return (str + '').replace(/([.?*+^$[\]\\(){}|-])/g, '\\$1');
5555
};
5656

@@ -59,7 +59,7 @@ export function escape_regex(str:string):string {
5959
* Cast object property to an array if it exists and has a value
6060
*
6161
*/
62-
export function propToArray(obj:{[key:string]:any}, key:string){
62+
export const propToArray = (obj:{[key:string]:any}, key:string) => {
6363
var value = obj[key];
6464
if( value && !Array.isArray(value) ){
6565
obj[key] = [value];
@@ -77,7 +77,7 @@ export function propToArray(obj:{[key:string]:any}, key:string){
7777
* ```
7878
*
7979
*/
80-
export function iterate(object:[]|{[key:string]:any}, callback:(value:any,key:number|string)=>any) {
80+
export const iterate = (object:[]|{[key:string]:any}, callback:(value:any,key:number|string)=>any) => {
8181

8282
if ( Array.isArray(object)) {
8383
object.forEach(callback);
@@ -94,7 +94,7 @@ export function iterate(object:[]|{[key:string]:any}, callback:(value:any,key:nu
9494

9595

9696

97-
export function cmp(a:number|string, b:number|string) {
97+
export const cmp = (a:number|string, b:number|string) => {
9898
if (typeof a === 'number' && typeof b === 'number') {
9999
return a > b ? 1 : (a < b ? -1 : 0);
100100
}

0 commit comments

Comments
 (0)