@@ -67,11 +67,12 @@ function applyWhen (fn, args) {
6767}
6868
6969function bindAll ( obj ) {
70- const names = Object . getOwnPropertyNames ( obj . prototype )
70+ const target = obj . prototype !== undefined ? obj : obj . prototype
71+ const names = Object . getOwnPropertyNames ( target )
7172 names . forEach ( name => {
72- const prop = obj . prototype [ name ]
73+ const prop = target [ name ]
7374 if ( typeof prop === 'function' ) {
74- obj [ prop ] = obj . prop . bind ( obj )
75+ obj [ prop ] = obj . prop . bind ( obj )
7576 }
7677 } )
7778}
@@ -90,8 +91,8 @@ function clone (source, target) {
9091 }
9192
9293 target = target || new source . constructor ( )
93- for ( var key in source ) {
94- target [ key ] = typeof target [ key ] === 'undefined' ? clone ( source [ key ] , null ) : target [ key ]
94+ for ( const key in source ) {
95+ target [ key ] = typeof target [ key ] === 'undefined' ? clone ( source [ key ] , null ) : target [ key ]
9596 }
9697 return target
9798}
@@ -102,9 +103,9 @@ function contains (list, value) {
102103
103104function defaults ( target , ...sources ) {
104105 sources . forEach ( ( source ) => {
105- for ( let key in source ) {
106- if ( ! target [ key ] ) {
107- target [ key ] = source [ key ]
106+ for ( const key in source ) {
107+ if ( ! target [ key ] ) {
108+ target [ key ] = source [ key ]
108109 }
109110 }
110111 } )
@@ -130,9 +131,9 @@ function find (list, predicate = y => y) {
130131 }
131132 let found = false
132133 let index = - 1
133- var item
134+ let item
134135 do {
135- item = list [ ++ index ]
136+ item = list [ ++ index ]
136137 found = predicate ( item )
137138 } while ( ! found && index < list . length - 1 )
138139 return found ? item : undefined
@@ -147,7 +148,7 @@ function flatten (list) {
147148function getArguments ( fn ) {
148149 const source = fn . toString ( ) . replace ( NYC_DEFAULT_REGEX , '' )
149150 const match = ARGUMENT_REGEX . exec ( source )
150- return filter ( match [ 2 ] . replace ( / [ ) ] / g, '' ) . split ( ',' ) )
151+ return filter ( match [ 2 ] . replace ( / [ ) ] / g, '' ) . split ( ',' ) )
151152 . map ( x => x . split ( '=' ) [ 0 ] )
152153}
153154
@@ -159,7 +160,7 @@ function getObjectTag (value) {
159160}
160161
161162function has ( object , key ) {
162- return object && exists ( object [ key ] )
163+ return object && exists ( object [ key ] )
163164}
164165
165166function intersection ( a , b ) {
@@ -246,23 +247,23 @@ function map (obj, fn) {
246247}
247248
248249function mapCall ( method , map ) {
249- let argumentList = getArguments ( method ) . slice ( 1 )
250+ const argumentList = getArguments ( method ) . slice ( 1 )
250251 if ( map === false ) {
251252 return method
252253 } else if ( map ) {
253254 return function ( actor , message ) {
254- let appliedArgs = [ actor ]
255+ const appliedArgs = [ actor ]
255256 argumentList . forEach ( ( arg ) => {
256- let prop = map [ arg ] ? map [ arg ] : arg
257- appliedArgs . push ( message [ prop ] )
257+ const prop = map [ arg ] ? map [ arg ] : arg
258+ appliedArgs . push ( message [ prop ] )
258259 } )
259260 return method . apply ( undefined , appliedArgs )
260261 }
261262 } else {
262263 return function ( actor , message ) {
263- let appliedArgs = [ actor ]
264+ const appliedArgs = [ actor ]
264265 argumentList . forEach ( ( arg ) => {
265- appliedArgs . push ( message [ arg ] )
266+ appliedArgs . push ( message [ arg ] )
266267 } )
267268 return method . apply ( undefined , appliedArgs )
268269 }
@@ -289,12 +290,12 @@ function parseFunction (fn) {
289290 const source = fn . toString ( ) . replace ( NYC_DEFAULT_REGEX , '' )
290291 const parts = FUNCTION_REGEX . exec ( source )
291292 return {
292- name : parts [ 2 ] ? parts [ 2 ] . trim ( ) : undefined ,
293- arguments : filter ( parts [ 3 ]
294- . replace ( / \s / g, '' )
293+ name : parts [ 2 ] ? parts [ 2 ] . trim ( ) : undefined ,
294+ arguments : filter ( parts [ 3 ]
295+ . replace ( / ( \s | [ \( ] ) / g, '' )
295296 . split ( ',' ) )
296297 . map ( x => x . split ( '=' ) [ 0 ] ) ,
297- body : parts [ 4 ]
298+ body : parts [ 4 ]
298299 }
299300}
300301
@@ -310,18 +311,18 @@ function sequence (...args) {
310311 if ( ! calls || calls . length === 0 ) {
311312 return Promise . resolve ( [ ] )
312313 }
313- let list = new Array ( calls . length )
314+ const list = new Array ( calls . length )
314315 let index = - 1
315316 function invoke ( ) {
316- const value = calls [ ++ index ] ( )
317+ const value = calls [ ++ index ] ( )
317318 if ( isPromisey ( value ) ) {
318319 return value . then ( next , next )
319320 } else {
320321 return next ( value )
321322 }
322323 }
323324 function next ( result ) {
324- list [ index ] = result
325+ list [ index ] = result
325326 if ( index < list . length - 1 ) {
326327 return invoke ( )
327328 } else {
@@ -333,9 +334,9 @@ function sequence (...args) {
333334
334335function sortBy ( list , prop ) {
335336 list . sort ( ( a , b ) => {
336- if ( a [ prop ] < b [ prop ] ) {
337+ if ( a [ prop ] < b [ prop ] ) {
337338 return - 1
338- } else if ( a [ prop ] > b [ prop ] ) {
339+ } else if ( a [ prop ] > b [ prop ] ) {
339340 return 1
340341 } else {
341342 return 0
@@ -348,7 +349,7 @@ function transform (obj, aliases, ...omit) {
348349 const list = flatten ( omit )
349350 return reduce ( obj , ( o , v , k ) => {
350351 if ( ! contains ( list , k ) ) {
351- o [ aliases [ k ] || k ] = v
352+ o [ aliases [ k ] || k ] = v
352353 }
353354 return o
354355 } , { } )
@@ -376,9 +377,9 @@ function uniq (original) {
376377}
377378
378379function unique ( list , identity = x => x ) {
379- let ids = [ ]
380+ const ids = [ ]
380381 return list . reduce ( ( acc , item ) => {
381- let id = identity ( item )
382+ const id = identity ( item )
382383 if ( ids . indexOf ( id ) < 0 ) {
383384 ids . push ( id )
384385 acc . push ( item )
0 commit comments