MCPcopy Create free account
hub / github.com/ampproject/amphtml / generateFunctionAllowlist

Function generateFunctionAllowlist

extensions/amp-bind/0.1/bind-expression.js:33–195  ·  view source on GitHub ↗

* @return {!{[key: string]: !{[key: string]: Function}}} * @private

()

Source from the content-addressed store, hash-verified

31 * @private
32 */
33function generateFunctionAllowlist() {
34 /**
35 * Deprecated. Static, not-in-place variant of Array#splice.
36 * @param {!Array} array
37 * @param {number=} unusedStart
38 * @param {number=} unusedDeleteCount
39 * @param {...?} unusedItems
40 * @return {!Array}
41 */
42 function splice(array, unusedStart, unusedDeleteCount, unusedItems) {
43 if (!isArray(array)) {
44 throw new Error(`splice: ${array} is not an array.`);
45 }
46 const copy = Array.prototype.slice.call(array);
47 const args = Array.prototype.slice.call(arguments, 1);
48 Array.prototype.splice.apply(copy, args);
49 return copy;
50 }
51
52 /**
53 * Needs to be wrapped to avoid a duplicate name conflict with the deprecated
54 * splice function above.
55 * @return {!Function}
56 */
57 function instanceSplice() {
58 /**
59 * @param {number=} unusedStart
60 * @param {number=} unusedDeleteCount
61 * @param {...?} unusedItems
62 * @return {!Array}
63 * @this {!Array}
64 */
65 function splice(unusedStart, unusedDeleteCount, unusedItems) {
66 const copy = Array.prototype.slice.call(this);
67 Array.prototype.splice.apply(copy, arguments);
68 return copy;
69 }
70 return splice;
71 }
72
73 /**
74 * Deprecated. Static, not-in-place variant of Array#sort.
75 * @param {!Array} array
76 * @return {!Array}
77 */
78 function sort(array) {
79 if (!isArray(array)) {
80 throw new Error(`sort: ${array} is not an array.`);
81 }
82 const copy = Array.prototype.slice.call(array);
83 Array.prototype.sort.call(copy);
84 return copy;
85 }
86
87 /**
88 * Needs to be wrapped to avoid a duplicate name conflict with the deprecated
89 * sort function above.
90 * @return {!Function}

Callers 1

constructorMethod · 0.85

Calls 5

mapFunction · 0.90
devAssertFunction · 0.90
instanceSortFunction · 0.85
instanceSpliceFunction · 0.85
forEachMethod · 0.45

Tested by

no test coverage detected