@@ -274,6 +274,16 @@ function createSupportObjects(config) {
274274 { } ,
275275 {
276276 get ( target , prop ) {
277+ // behavr like array or
278+ if ( prop === 'length' ) return Object . keys ( config ) . length
279+ if ( prop === Symbol . iterator ) {
280+ return function * ( ) {
281+ for ( let i = 0 ; i < Object . keys ( config ) . length ; i ++ ) {
282+ yield target [ i ]
283+ }
284+ }
285+ }
286+
277287 // load actual name from vocabulary
278288 if ( container . translation . name ) {
279289 name = container . translation . name
@@ -304,10 +314,10 @@ function createSupportObjects(config) {
304314 let currentValue = currentObject [ prop ]
305315
306316 if ( isFunction ( currentValue ) || isAsyncFunction ( currentValue ) ) {
307- const ms = new MetaStep ( name , currentValue )
317+ const ms = new MetaStep ( name , prop )
308318 ms . setContext ( currentObject )
309319 if ( isAsyncFunction ( currentValue ) ) currentValue = asyncWrapper ( currentValue )
310- currentObject [ prop ] = ms . run . bind ( ms , currentValue )
320+ return ms . run . bind ( ms , currentValue )
311321 }
312322
313323 return currentValue
@@ -317,8 +327,14 @@ function createSupportObjects(config) {
317327 return prop in container . support [ name ]
318328 } ,
319329 ownKeys ( ) {
330+ const keys = [ ]
331+ // Add numeric indices
332+ for ( let i = 0 ; i < Object . keys ( config ) . length ; i ++ ) {
333+ keys . push ( String ( i ) )
334+ }
335+ // Add other properties
320336 container . support [ name ] = container . support [ name ] || loadSupportObject ( config [ name ] )
321- return Reflect . ownKeys ( container . support [ name ] )
337+ return [ ... keys , ... Reflect . ownKeys ( container . support [ name ] ) ]
322338 } ,
323339 } ,
324340 )
@@ -350,8 +366,6 @@ function createActor(actorPath) {
350366 container . support . I = actor ( )
351367 }
352368
353- container . support . I = container . support . I
354-
355369 return container . support . I
356370}
357371
@@ -420,12 +434,16 @@ function loadSupportObject(modulePath, supportObjectName) {
420434 if ( typeof obj === 'function' ) {
421435 // If it's a class (constructor function)
422436 if ( obj . prototype && obj . prototype . constructor === obj ) {
423- const ClassName = obj ;
424- return new ClassName ( ) ;
437+ const ClassName = obj
438+ return new ClassName ( )
425439 }
426440 // If it's a regular function
427441 return obj ( )
428442 }
443+ if ( obj && Array . isArray ( obj ) ) {
444+ return obj
445+ }
446+
429447 // If it's a plain object
430448 if ( obj && typeof obj === 'object' && ! Array . isArray ( obj ) ) {
431449 return obj
0 commit comments