Skip to content

Commit

Permalink
[Refactor] use split-up es-abstract (79% bundle size decrease)
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Dec 19, 2019
1 parent 581a3db commit bb054d0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
10 changes: 6 additions & 4 deletions implementation.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
'use strict';

var ES = require('es-abstract/es5');
var IsCallable = require('es-abstract/2019/IsCallable');
var ToObject = require('es-abstract/2019/ToObject');
var ToUint32 = require('es-abstract/2019/ToUint32');
var callBound = require('es-abstract/helpers/callBound');
var isString = require('is-string');

Expand All @@ -11,16 +13,16 @@ var splitString = boxedString[0] !== 'a' || !(0 in boxedString);
var $split = callBound('String.prototype.split');

module.exports = function some(callbackfn) {
var O = ES.ToObject(this);
var O = ToObject(this);
var self = splitString && isString(O) ? $split(O, '') : O;
var len = ES.ToUint32(self.length);
var len = ToUint32(self.length);
var T;
if (arguments.length > 1) {
T = arguments[1];
}

// If no callback function or if callback is not a callable function
if (!ES.IsCallable(callbackfn)) {
if (!IsCallable(callbackfn)) {
throw new TypeError('Array.prototype.some callback must be a function');
}

Expand Down
9 changes: 5 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
'use strict';

var define = require('define-properties');
var ES = require('es-abstract/es2015');
var RequireObjectCoercible = require('es-abstract/2019/RequireObjectCoercible');
var callBound = require('es-abstract/helpers/callBound');

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

var slice = Array.prototype.slice;
var $slice = callBound('Array.prototype.slice');

// eslint-disable-next-line no-unused-vars
var boundEveryShim = function some(array, callbackfn) {
ES.RequireObjectCoercible(array);
return polyfill.apply(array, slice.call(arguments, 1));
RequireObjectCoercible(array);
return polyfill.apply(array, $slice(arguments, 1));
};
define(boundEveryShim, {
getPolyfill: getPolyfill,
Expand Down

0 comments on commit bb054d0

Please sign in to comment.