source: frontend/node_modules/underscore/amd/_methodFingerprint.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.7 KB
Line 
1define(['exports', './_getLength', './isFunction', './allKeys'], function (exports, _getLength, isFunction, allKeys) {
2
3 // Since the regular `Object.prototype.toString` type tests don't work for
4 // some types in IE 11, we use a fingerprinting heuristic instead, based
5 // on the methods. It's not great, but it's the best we got.
6 // The fingerprint method lists are defined below.
7 function ie11fingerprint(methods) {
8 var length = _getLength(methods);
9 return function(obj) {
10 if (obj == null) return false;
11 // `Map`, `WeakMap` and `Set` have no enumerable keys.
12 var keys = allKeys(obj);
13 if (_getLength(keys)) return false;
14 for (var i = 0; i < length; i++) {
15 if (!isFunction(obj[methods[i]])) return false;
16 }
17 // If we are testing against `WeakMap`, we need to ensure that
18 // `obj` doesn't have a `forEach` method in order to distinguish
19 // it from a regular `Map`.
20 return methods !== weakMapMethods || !isFunction(obj[forEachName]);
21 };
22 }
23
24 // In the interest of compact minification, we write
25 // each string in the fingerprints only once.
26 var forEachName = 'forEach',
27 hasName = 'has',
28 commonInit = ['clear', 'delete'],
29 mapTail = ['get', hasName, 'set'];
30
31 // `Map`, `WeakMap` and `Set` each have slightly different
32 // combinations of the above sublists.
33 var mapMethods = commonInit.concat(forEachName, mapTail),
34 weakMapMethods = commonInit.concat(mapTail),
35 setMethods = ['add'].concat(commonInit, forEachName, hasName);
36
37 exports.ie11fingerprint = ie11fingerprint;
38 exports.mapMethods = mapMethods;
39 exports.setMethods = setMethods;
40 exports.weakMapMethods = weakMapMethods;
41
42 Object.defineProperty(exports, '__esModule', { value: true });
43
44});
Note: See TracBrowser for help on using the repository browser.