@@ -12,7 +12,7 @@ import * as T from './types.ts';
12
12
* @param {String } name The optionally dotted property name to fetch
13
13
* @return {Object } The resolved property value
14
14
*/
15
- export function getAttr ( obj :{ [ key :string ] :any } , name :string ) {
15
+ export const getAttr = ( obj :{ [ key :string ] :any } , name :string ) => {
16
16
if ( ! obj ) return ;
17
17
return obj [ name ] ;
18
18
} ;
@@ -23,7 +23,7 @@ export function getAttr(obj:{[key:string]:any}, name:string ) {
23
23
* @param {String } name The optionally dotted property name to fetch
24
24
* @return {Object } The resolved property value
25
25
*/
26
- export function getAttrNesting ( obj :{ [ key :string ] :any } , name :string ) {
26
+ export const getAttrNesting = ( obj :{ [ key :string ] :any } , name :string ) => {
27
27
if ( ! obj ) return ;
28
28
var part , names = name . split ( "." ) ;
29
29
while ( ( part = names . shift ( ) ) && ( obj = obj [ part ] ) ) ;
@@ -35,7 +35,7 @@ export function getAttrNesting(obj:{[key:string]:any}, name:string ) {
35
35
* given value is against a search token.
36
36
*
37
37
*/
38
- export function scoreValue ( value :string , token :T . Token , weight :number ) :number {
38
+ export const scoreValue = ( value :string , token :T . Token , weight :number ) :number => {
39
39
var score , pos ;
40
40
41
41
if ( ! value ) return 0 ;
@@ -50,7 +50,7 @@ export function scoreValue(value:string, token:T.Token, weight:number ):number {
50
50
return score * weight ;
51
51
} ;
52
52
53
- export function escape_regex ( str :string ) :string {
53
+ export const escape_regex = ( str :string ) :string => {
54
54
return ( str + '' ) . replace ( / ( [ . ? * + ^ $ [ \] \\ ( ) { } | - ] ) / g, '\\$1' ) ;
55
55
} ;
56
56
@@ -59,7 +59,7 @@ export function escape_regex(str:string):string {
59
59
* Cast object property to an array if it exists and has a value
60
60
*
61
61
*/
62
- export function propToArray ( obj :{ [ key :string ] :any } , key :string ) {
62
+ export const propToArray = ( obj :{ [ key :string ] :any } , key :string ) => {
63
63
var value = obj [ key ] ;
64
64
if ( value && ! Array . isArray ( value ) ) {
65
65
obj [ key ] = [ value ] ;
@@ -77,7 +77,7 @@ export function propToArray(obj:{[key:string]:any}, key:string){
77
77
* ```
78
78
*
79
79
*/
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 ) => {
81
81
82
82
if ( Array . isArray ( object ) ) {
83
83
object . forEach ( callback ) ;
@@ -94,7 +94,7 @@ export function iterate(object:[]|{[key:string]:any}, callback:(value:any,key:nu
94
94
95
95
96
96
97
- export function cmp ( a :number | string , b :number | string ) {
97
+ export const cmp = ( a :number | string , b :number | string ) => {
98
98
if ( typeof a === 'number' && typeof b === 'number' ) {
99
99
return a > b ? 1 : ( a < b ? - 1 : 0 ) ;
100
100
}
0 commit comments