@d-i-t-a/reader 2.3.17 → 2.3.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -269,39 +269,65 @@
269
269
  "use strict";
270
270
  init_polyfills();
271
271
  var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ";
272
- var slice = Array.prototype.slice;
273
272
  var toStr = Object.prototype.toString;
273
+ var max = Math.max;
274
274
  var funcType = "[object Function]";
275
+ var concatty = function concatty2(a, b) {
276
+ var arr = [];
277
+ for (var i = 0; i < a.length; i += 1) {
278
+ arr[i] = a[i];
279
+ }
280
+ for (var j = 0; j < b.length; j += 1) {
281
+ arr[j + a.length] = b[j];
282
+ }
283
+ return arr;
284
+ };
285
+ var slicy = function slicy2(arrLike, offset) {
286
+ var arr = [];
287
+ for (var i = offset || 0, j = 0; i < arrLike.length; i += 1, j += 1) {
288
+ arr[j] = arrLike[i];
289
+ }
290
+ return arr;
291
+ };
292
+ var joiny = function(arr, joiner) {
293
+ var str = "";
294
+ for (var i = 0; i < arr.length; i += 1) {
295
+ str += arr[i];
296
+ if (i + 1 < arr.length) {
297
+ str += joiner;
298
+ }
299
+ }
300
+ return str;
301
+ };
275
302
  module.exports = function bind(that) {
276
303
  var target = this;
277
- if (typeof target !== "function" || toStr.call(target) !== funcType) {
304
+ if (typeof target !== "function" || toStr.apply(target) !== funcType) {
278
305
  throw new TypeError(ERROR_MESSAGE + target);
279
306
  }
280
- var args = slice.call(arguments, 1);
307
+ var args = slicy(arguments, 1);
281
308
  var bound;
282
309
  var binder = function() {
283
310
  if (this instanceof bound) {
284
311
  var result = target.apply(
285
312
  this,
286
- args.concat(slice.call(arguments))
313
+ concatty(args, arguments)
287
314
  );
288
315
  if (Object(result) === result) {
289
316
  return result;
290
317
  }
291
318
  return this;
292
- } else {
293
- return target.apply(
294
- that,
295
- args.concat(slice.call(arguments))
296
- );
297
319
  }
320
+ return target.apply(
321
+ that,
322
+ concatty(args, arguments)
323
+ );
298
324
  };
299
- var boundLength = Math.max(0, target.length - args.length);
325
+ var boundLength = max(0, target.length - args.length);
300
326
  var boundArgs = [];
301
327
  for (var i = 0; i < boundLength; i++) {
302
- boundArgs.push("$" + i);
328
+ boundArgs[i] = "$" + i;
303
329
  }
304
- bound = Function("binder", "return function (" + boundArgs.join(",") + "){ return binder.apply(this,arguments); }")(binder);
330
+ bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
305
331
  if (target.prototype) {
306
332
  var Empty = function Empty2() {
307
333
  };