added values(..)

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2020-05-23 16:38:43 +03:00
parent 8e31948e65
commit 7f8627d097
2 changed files with 43 additions and 1 deletions

View File

@ -188,6 +188,48 @@ function(obj, name, callback){
return res } return res }
// Get a list of values/props set in source objects for a prop/attr name...
//
// Get values...
// values(obj, name)
// values(obj, name, callback)
// -> list
// -> []
//
// Get propery descriptors...
// values(obj, name, true)
// values(obj, name, callback, true)
// -> list
// -> []
//
// callback(value, obj)
// -> true | 'stop'
// -> ..
//
//
var values =
module.values =
function(obj, name, callback, props){
props = callback === true ?
callback
: props
// wrap the callback if given...
var c = typeof(callback) == 'function'
&& function(obj){
return callback(
props ?
Object.getOwnPropertyDescriptor(obj, name)
: obj[name],
obj) }
return sources(...(c ?
[obj, name, c]
: arguments))
.map(function(obj){
return props ?
Object.getOwnPropertyDescriptor(obj, name)
: obj[name] }) }
// Find the next parent attribute in the prototype chain. // Find the next parent attribute in the prototype chain.
// //
// Get parent attribute value... // Get parent attribute value...

View File

@ -1,6 +1,6 @@
{ {
"name": "ig-object", "name": "ig-object",
"version": "4.0.2", "version": "4.0.3",
"description": "", "description": "",
"main": "object.js", "main": "object.js",
"scripts": { "scripts": {