Function

pattern
String
The property pattern to expand.
callback
Function
The callback to invoke. It is invoked once per expansion, and is passed the expansion.

Expands pattern, invoking callback for each expansion.

The only pattern supported is brace-expansion, anything else will be passed once to callback directly.

Example

1
2
3
4
5
6
7
8
9
10
11
import { expandProperties } from '@ember/object/computed';

function echo(arg){ console.log(arg); }

expandProperties('foo.bar', echo);              //=> 'foo.bar'
expandProperties('{foo,bar}', echo);            //=> 'foo', 'bar'
expandProperties('foo.{bar,baz}', echo);        //=> 'foo.bar', 'foo.baz'
expandProperties('{foo,bar}.baz', echo);        //=> 'foo.baz', 'bar.baz'
expandProperties('foo.{bar,baz}.[]', echo)      //=> 'foo.bar.[]', 'foo.baz.[]'
expandProperties('{foo,bar}.{spam,eggs}', echo) //=> 'foo.spam', 'foo.eggs', 'bar.spam', 'bar.eggs'
expandProperties('{foo}.bar.{baz}')             //=> 'foo.bar.baz'