Skip to content

Commit

Permalink
[New] shim/auto: add flat to Symbol.unscopables
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Apr 11, 2022
1 parent c22629d commit dd14f45
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"dependencies": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.3",
"es-abstract": "^1.19.2"
"es-abstract": "^1.19.2",
"es-shim-unscopables": "^1.0.0"
},
"devDependencies": {
"@es-shims/api": "^2.2.3",
Expand Down
6 changes: 6 additions & 0 deletions shim.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
'use strict';

var define = require('define-properties');
var shimUnscopables = require('es-shim-unscopables');

var getPolyfill = require('./polyfill');

module.exports = function shimFlat() {
var polyfill = getPolyfill();

define(
Array.prototype,
{ flat: polyfill },
{ flat: function () { return Array.prototype.flat !== polyfill; } }
);

shimUnscopables('flat');

return polyfill;
};

0 comments on commit dd14f45

Please sign in to comment.