array-fixed
Advanced tools
Comparing version 0.2.1 to 0.2.2
@@ -807,3 +807,17 @@ (function (global, factory) { | ||
value: function slice(begin, end) { | ||
return ArrayFixed.fromArray(this._array.slice(begin, end)); | ||
if (begin == null) begin = 0; | ||
if (end == null) end = this._array.length; | ||
if (begin < 0) { | ||
begin = Math.max(begin + this._array.length, 0); | ||
} | ||
if (end < 0) { | ||
end = Math.max(end + this._array.length, 0); | ||
} | ||
var count = void 0; | ||
if (this._direction) { | ||
count = Math.max(this._count - begin, 0) - Math.max(this._count - end, 0); | ||
} else { | ||
count = Math.max(end - this._count, 0) - Math.max(begin - this._count, 0); | ||
} | ||
return ArrayFixed.fromArray(this._array.slice(begin, end), count); | ||
} | ||
@@ -1660,3 +1674,17 @@ }, { | ||
value: function slice(begin, end) { | ||
return ArrayFixedDense.fromArray(this._array.slice(begin, end)); | ||
if (begin == null) begin = 0; | ||
if (end == null) end = this._array.length; | ||
if (begin < 0) { | ||
begin = Math.max(begin + this._array.length, 0); | ||
} | ||
if (end < 0) { | ||
end = Math.max(end + this._array.length, 0); | ||
} | ||
var count = void 0; | ||
if (this._direction) { | ||
count = Math.max(this._count - begin, 0) - Math.max(this._count - end, 0); | ||
} else { | ||
count = Math.max(end - this._count, 0) - Math.max(begin - this._count, 0); | ||
} | ||
return ArrayFixedDense.fromArray(this._array.slice(begin, end), count, this._direction); | ||
} | ||
@@ -1663,0 +1691,0 @@ }, { |
@@ -107,3 +107,17 @@ 'use strict'; | ||
slice(begin, end) { | ||
return ArrayFixed.fromArray(this._array.slice(begin, end)); | ||
if (begin == null) begin = 0; | ||
if (end == null) end = this._array.length; | ||
if (begin < 0) { | ||
begin = Math.max(begin + this._array.length, 0); | ||
} | ||
if (end < 0) { | ||
end = Math.max(end + this._array.length, 0); | ||
} | ||
let count; | ||
if (this._direction) { | ||
count = Math.max(this._count - begin, 0) - Math.max(this._count - end, 0); | ||
} else { | ||
count = Math.max(end - this._count, 0) - Math.max(begin - this._count, 0); | ||
} | ||
return ArrayFixed.fromArray(this._array.slice(begin, end), count); | ||
} | ||
@@ -291,3 +305,17 @@ | ||
slice(begin, end) { | ||
return ArrayFixedDense.fromArray(this._array.slice(begin, end)); | ||
if (begin == null) begin = 0; | ||
if (end == null) end = this._array.length; | ||
if (begin < 0) { | ||
begin = Math.max(begin + this._array.length, 0); | ||
} | ||
if (end < 0) { | ||
end = Math.max(end + this._array.length, 0); | ||
} | ||
let count; | ||
if (this._direction) { | ||
count = Math.max(this._count - begin, 0) - Math.max(this._count - end, 0); | ||
} else { | ||
count = Math.max(end - this._count, 0) - Math.max(begin - this._count, 0); | ||
} | ||
return ArrayFixedDense.fromArray(this._array.slice(begin, end), count, this._direction); | ||
} | ||
@@ -294,0 +322,0 @@ |
@@ -101,3 +101,17 @@ import _getIterator from 'babel-runtime/core-js/get-iterator'; | ||
slice(begin, end) { | ||
return ArrayFixed.fromArray(this._array.slice(begin, end)); | ||
if (begin == null) begin = 0; | ||
if (end == null) end = this._array.length; | ||
if (begin < 0) { | ||
begin = Math.max(begin + this._array.length, 0); | ||
} | ||
if (end < 0) { | ||
end = Math.max(end + this._array.length, 0); | ||
} | ||
let count; | ||
if (this._direction) { | ||
count = Math.max(this._count - begin, 0) - Math.max(this._count - end, 0); | ||
} else { | ||
count = Math.max(end - this._count, 0) - Math.max(begin - this._count, 0); | ||
} | ||
return ArrayFixed.fromArray(this._array.slice(begin, end), count); | ||
} | ||
@@ -285,3 +299,17 @@ | ||
slice(begin, end) { | ||
return ArrayFixedDense.fromArray(this._array.slice(begin, end)); | ||
if (begin == null) begin = 0; | ||
if (end == null) end = this._array.length; | ||
if (begin < 0) { | ||
begin = Math.max(begin + this._array.length, 0); | ||
} | ||
if (end < 0) { | ||
end = Math.max(end + this._array.length, 0); | ||
} | ||
let count; | ||
if (this._direction) { | ||
count = Math.max(this._count - begin, 0) - Math.max(this._count - end, 0); | ||
} else { | ||
count = Math.max(end - this._count, 0) - Math.max(begin - this._count, 0); | ||
} | ||
return ArrayFixedDense.fromArray(this._array.slice(begin, end), count, this._direction); | ||
} | ||
@@ -288,0 +316,0 @@ |
@@ -99,3 +99,17 @@ // @flow | ||
slice (begin: ?number, end: ?number): ArrayFixed<item> { | ||
return ArrayFixed.fromArray(this._array.slice(begin, end)); | ||
if (begin == null) begin = 0; | ||
if (end == null) end = this._array.length; | ||
if (begin < 0) { | ||
begin = Math.max(begin + this._array.length, 0); | ||
} | ||
if (end < 0) { | ||
end = Math.max(end + this._array.length, 0); | ||
} | ||
let count; | ||
if (this._direction) { | ||
count = Math.max(this._count - begin, 0) - Math.max(this._count - end, 0); | ||
} else { | ||
count = Math.max(end - this._count, 0) - Math.max(begin - this._count, 0); | ||
} | ||
return ArrayFixed.fromArray(this._array.slice(begin, end), count); | ||
} | ||
@@ -102,0 +116,0 @@ |
@@ -131,3 +131,21 @@ // @flow | ||
slice (begin: ?number, end: ?number): ArrayFixedDense<item> { | ||
return ArrayFixedDense.fromArray(this._array.slice(begin, end)); | ||
if (begin == null) begin = 0; | ||
if (end == null) end = this._array.length; | ||
if (begin < 0) { | ||
begin = Math.max(begin + this._array.length, 0); | ||
} | ||
if (end < 0) { | ||
end = Math.max(end + this._array.length, 0); | ||
} | ||
let count; | ||
if (this._direction) { | ||
count = Math.max(this._count - begin, 0) - Math.max(this._count - end, 0); | ||
} else { | ||
count = Math.max(end - this._count, 0) - Math.max(begin - this._count, 0); | ||
} | ||
return ArrayFixedDense.fromArray( | ||
this._array.slice(begin, end), | ||
count, | ||
this._direction | ||
); | ||
} | ||
@@ -134,0 +152,0 @@ |
{ | ||
"name": "array-fixed", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "Array with a Fixed Preallocated Length", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
97805
2451