Skip to content

Commit 57453c6

Browse files
author
daniel-lundin
committed
Added polyfill for Array.prototype.find
1 parent 0350cde commit 57453c6

File tree

4 files changed

+50
-12
lines changed

4 files changed

+50
-12
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"author": "Daniel Lundin",
2626
"license": "MIT",
2727
"devDependencies": {
28+
"array.prototype.find": "^1.0.0",
2829
"babelify": "^6.3.0",
2930
"chai": "^3.3.0",
3031
"chai-string": "^1.1.4",

snabbt.js

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,39 @@
1-
/* snabbt.js Version: 0.6.2 Build date: 2015-12-16 (c) 2015 Daniel Lundin @license MIT */
21
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.snabbt = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2+
// Array.prototype.find - MIT License (c) 2013 Paul Miller <http://paulmillr.com>
3+
// For all details and docs: https://github.com/paulmillr/array.prototype.find
4+
// Fixes and tests supplied by Duncan Hall <http://duncanhall.net>
5+
(function(globals){
6+
if (Array.prototype.find) return;
7+
8+
var find = function(predicate) {
9+
var list = Object(this);
10+
var length = list.length < 0 ? 0 : list.length >>> 0; // ES.ToUint32;
11+
if (length === 0) return undefined;
12+
if (typeof predicate !== 'function' || Object.prototype.toString.call(predicate) !== '[object Function]') {
13+
throw new TypeError('Array#find: predicate must be a function');
14+
}
15+
var thisArg = arguments[1];
16+
for (var i = 0, value; i < length; i++) {
17+
value = list[i];
18+
if (predicate.call(thisArg, value, i, list)) return value;
19+
}
20+
return undefined;
21+
};
22+
23+
if (Object.defineProperty) {
24+
try {
25+
Object.defineProperty(Array.prototype, 'find', {
26+
value: find, configurable: true, enumerable: false, writable: true
27+
});
28+
} catch(e) {}
29+
}
30+
31+
if (!Array.prototype.find) {
32+
Array.prototype.find = find;
33+
}
34+
})(this);
35+
36+
},{}],2:[function(require,module,exports){
337
'use strict';
438
var utils = require('./utils.js');
539
var easing = require('./easing.js');
@@ -220,7 +254,7 @@ module.exports = {
220254
createAttentionAnimation: createAttentionAnimation
221255
};
222256

223-
},{"./easing.js":2,"./state.js":7,"./tweeners":8,"./utils.js":9}],2:[function(require,module,exports){
257+
},{"./easing.js":3,"./state.js":8,"./tweeners":9,"./utils.js":10}],3:[function(require,module,exports){
224258
'use strict';
225259

226260
var utils = require('./utils.js');
@@ -338,7 +372,7 @@ module.exports = {
338372
createSpringEasing: createSpringEasing
339373
};
340374

341-
},{"./utils.js":9}],3:[function(require,module,exports){
375+
},{"./utils.js":10}],4:[function(require,module,exports){
342376
'use strict';
343377
/* global document, window */
344378
var stateFromOptions = require('./state.js').stateFromOptions;
@@ -527,10 +561,12 @@ var Engine = {
527561

528562
module.exports = Engine;
529563

530-
},{"./animation.js":1,"./state.js":7,"./utils.js":9}],4:[function(require,module,exports){
564+
},{"./animation.js":2,"./state.js":8,"./utils.js":10}],5:[function(require,module,exports){
531565
'use strict';
532566
/* global window */
533567

568+
require('array.prototype.find');
569+
534570
var Engine = require('./engine.js');
535571
var preprocessOptions = require('./properties.js').preprocessOptions;
536572
var utils = require('./utils.js');
@@ -625,7 +661,7 @@ if (typeof window !== 'undefined' && window.jQuery) {
625661

626662
Engine.init();
627663

628-
},{"./engine.js":3,"./matrix.js":5,"./properties.js":6,"./utils.js":9}],5:[function(require,module,exports){
664+
},{"./engine.js":4,"./matrix.js":6,"./properties.js":7,"./utils.js":10,"array.prototype.find":1}],6:[function(require,module,exports){
629665
'use strict';
630666

631667
function assignedMatrixMultiplication(a, b, res) {
@@ -881,7 +917,7 @@ function createMatrix() {
881917

882918
module.exports = createMatrix;
883919

884-
},{}],6:[function(require,module,exports){
920+
},{}],7:[function(require,module,exports){
885921
'use strict';
886922

887923
var utils = require('./utils.js');
@@ -971,7 +1007,7 @@ module.exports = {
9711007
}
9721008
};
9731009

974-
},{"./utils.js":9}],7:[function(require,module,exports){
1010+
},{"./utils.js":10}],8:[function(require,module,exports){
9751011
'use strict';
9761012

9771013
var createMatrix = require('./matrix.js');
@@ -1080,7 +1116,7 @@ module.exports = {
10801116
stateFromOptions: stateFromOptions
10811117
};
10821118

1083-
},{"./matrix.js":5,"./properties.js":6,"./utils.js":9}],8:[function(require,module,exports){
1119+
},{"./matrix.js":6,"./properties.js":7,"./utils.js":10}],9:[function(require,module,exports){
10841120
'use strict';
10851121

10861122
var createMatrix = require('./matrix.js');
@@ -1198,7 +1234,7 @@ module.exports = {
11981234
createValueFeederTweener: createValueFeederTweener
11991235
};
12001236

1201-
},{"./matrix.js":5,"./properties":6}],9:[function(require,module,exports){
1237+
},{"./matrix.js":6,"./properties":7}],10:[function(require,module,exports){
12021238
'use strict';
12031239

12041240
function isFunction(object) {
@@ -1253,5 +1289,5 @@ module.exports = {
12531289
findUltimateAncestor: findUltimateAncestor
12541290
};
12551291

1256-
},{}]},{},[4])(4)
1292+
},{}]},{},[5])(5)
12571293
});

0 commit comments

Comments
 (0)