Skip to content

Commit

Permalink
Resolves omniscientjs#89
Browse files Browse the repository at this point in the history
  • Loading branch information
dashed committed Mar 6, 2015
1 parent f7d4afd commit f9772ed
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 265 deletions.
289 changes: 26 additions & 263 deletions dist/omniscient.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,10 +434,18 @@ var shouldupdate = _dereq_('./shouldupdate');
* You can do this if you want to define functions that caches computed
* result to avoid recomputing if invoked with equal arguments as last time.
*
* Returns optimized version of given `f` function for repeated
* calls with an equal inputs. Returned function caches last input
* and a result of the computation for it, which is handy for
* optimizing `render` when computations are run on unchanged parts
* of state. Although note that only last result is cached so it is
* not practical to call it mulitple times with in the same `render`
* call.
*
* @param {Function} Function that does a computation.
*
* @module cached
* @returns {Function}
* @returns {Function} Optimized function
* @api public
*/
module.exports = factory();
Expand All @@ -463,21 +471,6 @@ module.exports.withDefaults = factory;
function factory (methods) {
var isEqual = (methods && methods.isEqualProps) || shouldupdate.isEqualProps;

/**
* Returns optimized version of given `f` function for repeated
* calls with an equal inputs. Returned function caches last input
* and a result of the computation for it, which is handy for
* optimizing `render` when computations are run on unchanged parts
* of state. Although note that only last result is cached so it is
* not practical to call it mulitple times with in the same `render`
* call.
*
* @param {Function} function doing computation
*
* @module shouldComponentUpdate.isEqualState
* @returns {Function} Optimized function.
* @api public
*/
return function cached (f) {
var input,
output;
Expand Down Expand Up @@ -1331,10 +1324,10 @@ module.exports = bindCallback;

},{}],12:[function(_dereq_,module,exports){
/**
* lodash 3.0.2 (Custom Build) <https://lodash.com/>
* lodash 3.0.3 (Custom Build) <https://lodash.com/>
* Build: `lodash modern modularize exports="npm" -o ./`
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.7.0 <http://underscorejs.org/LICENSE>
* Based on Underscore.js 1.8.2 <http://underscorejs.org/LICENSE>
* Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <https://lodash.com/license>
*/
Expand Down Expand Up @@ -1380,8 +1373,11 @@ function isIterateeCall(value, index, object) {
} else {
prereq = type == 'string' && index in object;
}
var other = object[index];
return prereq && (value === value ? value === other : other !== other);
if (prereq) {
var other = object[index];
return value === value ? value === other : other !== other;
}
return false;
}

/**
Expand Down Expand Up @@ -1951,246 +1947,8 @@ function isTypedArray(value) {
module.exports = isTypedArray;

},{}],17:[function(_dereq_,module,exports){
/**
* lodash 3.0.2 (Custom Build) <https://lodash.com/>
* Build: `lodash modern modularize exports="npm" -o ./`
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.7.0 <http://underscorejs.org/LICENSE>
* Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
* Available under MIT license <https://lodash.com/license>
*/
var isArguments = _dereq_('lodash.isarguments'),
isArray = _dereq_('lodash.isarray'),
isNative = _dereq_('lodash.isnative');

/** Used for native method references. */
var objectProto = Object.prototype;

/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;

/** Native method references. */
var propertyIsEnumerable = objectProto.propertyIsEnumerable;

/* Native method references for those with the same name as other `lodash` methods. */
var nativeKeys = isNative(nativeKeys = Object.keys) && nativeKeys;

/**
* Used as the maximum length of an array-like value.
* See the [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer)
* for more details.
*/
var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1;

/**
* An object environment feature flags.
*
* @static
* @memberOf _
* @type Object
*/
var support = {};

(function(x) {

/**
* Detect if `arguments` object indexes are non-enumerable.
*
* In Firefox < 4, IE < 9, PhantomJS, and Safari < 5.1 `arguments` object
* indexes are non-enumerable. Chrome < 25 and Node.js < 0.11.0 treat
* `arguments` object indexes as non-enumerable and fail `hasOwnProperty`
* checks for indexes that exceed their function's formal parameters with
* associated values of `0`.
*
* @memberOf _.support
* @type boolean
*/
try {
support.nonEnumArgs = !propertyIsEnumerable.call(arguments, 1);
} catch(e) {
support.nonEnumArgs = true;
}
}(0, 0));

/**
* Checks if `value` is a valid array-like index.
*
* @private
* @param {*} value The value to check.
* @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
* @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
*/
function isIndex(value, length) {
value = +value;
length = length == null ? MAX_SAFE_INTEGER : length;
return value > -1 && value % 1 == 0 && value < length;
}

/**
* Checks if `value` is a valid array-like length.
*
* **Note:** This function is based on ES `ToLength`. See the
* [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength)
* for more details.
*
* @private
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
*/
function isLength(value) {
return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
}

/**
* A fallback implementation of `Object.keys` which creates an array of the
* own enumerable property names of `object`.
*
* @private
* @param {Object} object The object to inspect.
* @returns {Array} Returns the array of property names.
*/
function shimKeys(object) {
var props = keysIn(object),
propsLength = props.length,
length = propsLength && object.length;

var allowIndexes = length && isLength(length) &&
(isArray(object) || (support.nonEnumArgs && isArguments(object)));

var index = -1,
result = [];

while (++index < propsLength) {
var key = props[index];
if ((allowIndexes && isIndex(key, length)) || hasOwnProperty.call(object, key)) {
result.push(key);
}
}
return result;
}

/**
* Checks if `value` is the language type of `Object`.
* (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
*
* **Note:** See the [ES5 spec](https://es5.github.io/#x8) for more details.
*
* @static
* @memberOf _
* @category Lang
* @param {*} value The value to check.
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
* @example
*
* _.isObject({});
* // => true
*
* _.isObject([1, 2, 3]);
* // => true
*
* _.isObject(1);
* // => false
*/
function isObject(value) {
// Avoid a V8 JIT bug in Chrome 19-20.
// See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
var type = typeof value;
return type == 'function' || (value && type == 'object') || false;
}

/**
* Creates an array of the own enumerable property names of `object`.
*
* **Note:** Non-object values are coerced to objects. See the
* [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.keys)
* for more details.
*
* @static
* @memberOf _
* @category Object
* @param {Object} object The object to inspect.
* @returns {Array} Returns the array of property names.
* @example
*
* function Foo() {
* this.a = 1;
* this.b = 2;
* }
*
* Foo.prototype.c = 3;
*
* _.keys(new Foo);
* // => ['a', 'b'] (iteration order is not guaranteed)
*
* _.keys('hi');
* // => ['0', '1']
*/
var keys = !nativeKeys ? shimKeys : function(object) {
if (object) {
var Ctor = object.constructor,
length = object.length;
}
if ((typeof Ctor == 'function' && Ctor.prototype === object) ||
(typeof object != 'function' && (length && isLength(length)))) {
return shimKeys(object);
}
return isObject(object) ? nativeKeys(object) : [];
};

/**
* Creates an array of the own and inherited enumerable property names of `object`.
*
* **Note:** Non-object values are coerced to objects.
*
* @static
* @memberOf _
* @category Object
* @param {Object} object The object to inspect.
* @returns {Array} Returns the array of property names.
* @example
*
* function Foo() {
* this.a = 1;
* this.b = 2;
* }
*
* Foo.prototype.c = 3;
*
* _.keysIn(new Foo);
* // => ['a', 'b', 'c'] (iteration order is not guaranteed)
*/
function keysIn(object) {
if (object == null) {
return [];
}
if (!isObject(object)) {
object = Object(object);
}
var length = object.length;
length = (length && isLength(length) &&
(isArray(object) || (support.nonEnumArgs && isArguments(object))) && length) || 0;

var Ctor = object.constructor,
index = -1,
isProto = typeof Ctor == 'function' && Ctor.prototype == object,
result = Array(length),
skipIndexes = length > 0;

while (++index < length) {
result[index] = (index + '');
}
for (var key in object) {
if (!(skipIndexes && isIndex(key, length)) &&
!(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
result.push(key);
}
}
return result;
}

module.exports = keys;

},{"lodash.isarguments":18,"lodash.isarray":15,"lodash.isnative":19}],18:[function(_dereq_,module,exports){
arguments[4][6][0].apply(exports,arguments)
},{"dup":6,"lodash.isarguments":18,"lodash.isarray":15,"lodash.isnative":19}],18:[function(_dereq_,module,exports){
arguments[4][7][0].apply(exports,arguments)
},{"dup":7}],19:[function(_dereq_,module,exports){
arguments[4][9][0].apply(exports,arguments)
Expand Down Expand Up @@ -2539,7 +2297,7 @@ module.exports = baseFor;

},{}],29:[function(_dereq_,module,exports){
/**
* lodash 3.0.2 (Custom Build) <https://lodash.com/>
* lodash 3.0.3 (Custom Build) <https://lodash.com/>
* Build: `lodash modern modularize exports="npm" -o ./`
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/>
* Based on Underscore.js 1.7.0 <http://underscorejs.org/LICENSE>
Expand Down Expand Up @@ -2688,7 +2446,7 @@ function keysIn(object) {

var Ctor = object.constructor,
index = -1,
isProto = typeof Ctor == 'function' && Ctor.prototype == object,
isProto = typeof Ctor == 'function' && Ctor.prototype === object,
result = Array(length),
skipIndexes = length > 0;

Expand Down Expand Up @@ -2870,7 +2628,12 @@ function factory (methods) {
* @api public
*/
function isEqualCursor (a, b) {
return _unCursor(a) === _unCursor(b);
var
n = a._keyPath.length - 1,
m = n >= 0 ? n : 0;
return _unCursor(a) === _unCursor(b) &&
n === b._keyPath.length &&
a._keyPath[m] === b._keyPath[m];
}

function debugFn (pattern, logFn) {
Expand Down
Loading

0 comments on commit f9772ed

Please sign in to comment.