diff --git a/README.md b/README.md index 6e9dac0..5001b62 100755 --- a/README.md +++ b/README.md @@ -133,6 +133,7 @@ class B extends A { - [`Constructor(..)` / `C(..)`](#constructor--c) - [`create(..)` / `Constructor.create(..)`](#create--constructorcreate) - [`sources(..)` / `Constructor.sources(..)`](#sources--constructorsources) + - [`entries(..)` / `Constructor.entries(..)`](#entries--constructorentries) - [`values(..)` / `Constructor.values(..)`](#values--constructorvalues) - [`parent(..)` / `Constructor.parent(..)`](#parent--constructorparent) - [`parentProperty(..)` / `Constructor.parentProperty(..)`](#parentproperty--constructorparentproperty) @@ -638,92 +639,71 @@ This is similar to [`Object.create(..)`] but handles callables correctly, i.e. i ### `sources(..)` / `Constructor.sources(..)` -Get sources for attribute +Iterate the sources for attribute ``` +sources() sources(, ) -sources(, , ) - -> + -> ``` -``` -callback(, ) - -> STOP - -> STOP() - -> undefined - -> -``` - -The `callback(..)` controls the output of `sources(..)` by returning -one of the following: - -- `object.STOP` - This will make `sources(..)` stop and return the `` up to and - including the object that triggered the _stop_. -- `object.STOP()` - Same as returning `object.STOP` but will put the `` at the end of - the returned list instead of the input object. -- `undefined` - Add the object triggering `callback(..)` in `` as-is and continue. -- array - The containing values will be merged into the result list and continue. - This is a way to either skip an object by returning `[]` or multiple - values instead of one. -- `` - Add to the resulting `` as-is instead of the object triggering - `callback(..)` and continue. - +If no name is given iterate through all the parents. Special case: get callable implementations ``` -sources(, '__call__', ..) - -> +sources(, '__call__') + -> ``` -This will get the callable implementations regardless of the actual +This will iterate the callable implementations regardless of the actual implementation details, i.e. both function prototype or `.__call__(..)` methods will be matched. -### `values(..)` / `Constructor.values(..)` +### `entries(..)` / `Constructor.entries(..)` -Get values for attribute in prototype chain +Iterate ``-`` pairs for attribute in the prototype chain. ``` -values(, ) -values(, , ) - -> -``` - -``` -callback(, , ) - -> STOP - -> undefined - -> +entries(, ) + -> ``` -Get property descriptors for attribute in prototype chain +Iterate property descriptors for attribute in prototype chain ``` -values(, , true) -values(, , , true) - -> +entries(, , true) + -> ``` -``` -callback(, ) - -> STOP - -> STOP(value) - -> undefined - -> -``` - - Special case: get callable implementations ``` -values(, '__call__', ..) +entries(, '__call__') + -> +``` + +This will yield the callable objects themselves or the value of `.__call__`. + + +### `values(..)` / `Constructor.values(..)` + +Iterate values for attribute in prototype chain +``` +values(, ) + -> +``` + +Iterate property descriptors for attribute in prototype chain +``` +values(, , true) -> ``` -This will return the callable objects themselves or the value of `.__call__`. +Special case: get callable implementations +``` +values(, '__call__') + -> +``` + +This will yield the callable objects themselves or the value of `.__call__`. See [`sources(..)`](#sources--constructorsources) for docs on `callback(..)` diff --git a/object.js b/object.js index 4dbbef1..e375c8b 100755 --- a/object.js +++ b/object.js @@ -423,7 +423,7 @@ function*(obj, name=undefined){ // // Item format: // [ -// object, +// source, // value, // ] // @@ -453,14 +453,6 @@ function*(obj, name, props=false){ // Get values/props set in source objects for a prop/attr name... // -// values(obj, name) -// -> iterator -// -// Get propery descriptors... -// values(obj, name, true) -// -> iterator -// -// // NOTE: this is specialization of entries(..), see that for more info. var values = module.values =