mirror of
https://github.com/pebble-dev/clay.git
synced 2026-09-03 07:37:46 -04:00
Refactor structure to be more testable
This commit is contained in:
+127
-4
@@ -1,8 +1,8 @@
|
||||
// minified.js config start -- use this comment to re-create a configuration in the Builder
|
||||
// - Only sections add, always, amdsupport, dollardollar, each,
|
||||
// - eachobj, error, extend, filter, find, format, formathtml, get, html, isobject,
|
||||
// - map, mapobj, off, on, ready, request, select, set, template, trigger,
|
||||
// - underscore, wait.
|
||||
// - Only sections add, always, amdsupport, copyobj, dollardollar,
|
||||
// - each, eachobj, error, extend, filter, filterobj, find, format, formathtml,
|
||||
// - get, ht, html, isobject, keys, map, mapobj, objvalues, off, on, ready,
|
||||
// - request, select, set, template, trigger, underscore, wait.
|
||||
|
||||
|
||||
// WARNING! This file is autogenerated from minified-master.js and others.
|
||||
@@ -2741,6 +2741,89 @@ define('minified', function() {
|
||||
'find': find,
|
||||
// @condend
|
||||
|
||||
/*$
|
||||
* @id keys
|
||||
* @group OBJECT
|
||||
* @requires
|
||||
* @configurable default
|
||||
* @name _.keys()
|
||||
* @syntax _.keys(obj)
|
||||
* @module UTIL
|
||||
* Creates a ##list#Minified list## containing all property names of the specified object. Only direct properies are
|
||||
* included, not inherited ones. The order of the keys in the list is undefined and runtime-specific.
|
||||
*
|
||||
* @example Using <var>keys()</var>:
|
||||
* <pre>var obj = {a: 2, b: 52};
|
||||
* var keys = _.keys(obj); // keys contains ['a', 'b'] now
|
||||
* </pre>
|
||||
*
|
||||
* @param object The object to gather keys from.
|
||||
* @return A Minified list containing the property names.
|
||||
*
|
||||
* @see ##_.values() returns the values of an object as a list.
|
||||
*/
|
||||
'keys': funcArrayBind(keys),
|
||||
|
||||
/*$
|
||||
* @id objvalues
|
||||
* @group OBJECT
|
||||
* @requires
|
||||
* @configurable default
|
||||
* @name _.values()
|
||||
* @syntax _.values(obj)
|
||||
* @module UTIL
|
||||
* Creates a ##list#Minified list## containing all property values of the specified object. Only direct properies are
|
||||
* included, not inherited ones. The order of the values in the list is undefined and runtime-specific.
|
||||
*
|
||||
* @example Using <var>values()</var>:
|
||||
* <pre>var obj = {a: 2, b: 52};
|
||||
* var values = _.values(obj); // keys contains [2, 52] now
|
||||
* </pre>
|
||||
*
|
||||
* @param object The object to gather values from.
|
||||
* @return A Minified list containing the property names.
|
||||
*
|
||||
* @see ##_.keys() retrieves the property names of an object as a list.
|
||||
*/
|
||||
'values': funcArrayBind(function(obj, keys) {
|
||||
var list = [];
|
||||
if (keys)
|
||||
each(keys, function(value) { list.push(obj[value]); });
|
||||
else
|
||||
eachObj(obj, function(key, value) { list.push(value); });
|
||||
return list;
|
||||
}),
|
||||
|
||||
/*$
|
||||
* @id copyobj
|
||||
* @group OBJECT
|
||||
* @requires
|
||||
* @configurable default
|
||||
* @name _.copyObj()
|
||||
* @syntax _.copyObj(from)
|
||||
* @syntax _.copyObj(from, to)
|
||||
* @module UTIL
|
||||
* Copies every property of the first object into the second object. The properties are copied as shallow-copies.
|
||||
*
|
||||
* @example Copying properties:
|
||||
* <pre>var target = {a:3, c: 3};
|
||||
* _.copyObj({a: 1, b: 2}, target); // target is now {a: 1, b: 2, c: 3}</pre>
|
||||
*
|
||||
* @example Inline property merge:
|
||||
* <pre>var target = _.copyObj({a: 1, b: 2}, {a:3, c: 3}); // target is now {a: 1, b: 2, c: 3}</pre>
|
||||
*
|
||||
* @example Duplicating an object:
|
||||
* <pre>var target = _.copyObj({a: 1, b: 2}); // target is now {a: 1, b: 2}</pre>
|
||||
*
|
||||
* @param from the object to copy from
|
||||
* @param to optional the object to copy to. If not given, a new object will be created.
|
||||
* @return the object that has been copied to
|
||||
*
|
||||
* @see ##_.extend() is very similar to <var>copyObj()</var>, but with a slightly different syntax.
|
||||
* @see ##_.merge() copies a list of objects into a new object.
|
||||
*/
|
||||
'copyObj': copyObj,
|
||||
|
||||
/*$
|
||||
* @id extend
|
||||
* @group OBJECT
|
||||
@@ -2848,6 +2931,46 @@ define('minified', function() {
|
||||
return result;
|
||||
},
|
||||
|
||||
/*$
|
||||
* @id filterobj
|
||||
* @group OBJECT
|
||||
* @requires
|
||||
* @configurable default
|
||||
* @name _.filterObj()
|
||||
* @syntax _.filterObj(obj, filterFunc)
|
||||
* @syntax _.filterObj(obj, filterFunc, ctx)
|
||||
* @module UTIL
|
||||
* Creates a new object that contains only those properties of the input object that have been approved by the filter function.
|
||||
*
|
||||
* If the callback function returns true, the property and its value are shallow-copied in the new object, otherwise it will be removed.
|
||||
*
|
||||
* @example Removing all values over 10 from an object:
|
||||
* <pre>
|
||||
* var list = _.filterObj({a: 4, b: 22, c: 7, d: 2, e: 19}, function(key, value) {
|
||||
* return value <= 10;
|
||||
* });
|
||||
* </pre>
|
||||
*
|
||||
* @param obj the object to use
|
||||
* @param callback The callback <code>function(key, value)</code> to invoke for each property.
|
||||
* <dl><dt>key</dt><dd>The name of the current property.</dd>
|
||||
* <dt>value</dt><dd>The value of the current property.</dd>
|
||||
* <dt class="this">this</dt><dd>The given context. If not set, the object itself.</dd>
|
||||
* <dt class="returnValue">(callback return value)</dt><dd><var>true</var> to include the property in the new object, <var>false</var> to omit it.</dd></dl>
|
||||
* @param ctx optional a context to pass to the callback as 'this'.
|
||||
* @return the new object
|
||||
*
|
||||
* @see ##_.mapObj() can be used to modify the values og an object.
|
||||
*/
|
||||
'filterObj': function(obj, f, ctx) {
|
||||
var r = {};
|
||||
eachObj(obj, function(key, value) {
|
||||
if (f.call(ctx || obj, key, value))
|
||||
r[key] = value;
|
||||
});
|
||||
return r;
|
||||
},
|
||||
|
||||
/*$
|
||||
* @id isobject
|
||||
* @group TYPE
|
||||
|
||||
Reference in New Issue
Block a user