mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Shorten Base.read() a bit.
This commit is contained in:
parent
6b4f142838
commit
13dd088043
1 changed files with 6 additions and 7 deletions
13
src/paper.js
13
src/paper.js
|
@ -58,16 +58,15 @@ Base.inject({
|
||||||
read: function(list, start, length) {
|
read: function(list, start, length) {
|
||||||
var start = start || 0,
|
var start = start || 0,
|
||||||
length = length || list.length - start;
|
length = length || list.length - start;
|
||||||
var arg = list[start];
|
var obj = list[start];
|
||||||
// If the class defines _readNull, return null when nothing was provided
|
// If the class defines _readNull, return null when nothing was provided
|
||||||
if (arg instanceof this
|
if (obj instanceof this
|
||||||
|| this.prototype._readNull && arg == null && length <= 1)
|
|| this.prototype._readNull && obj == null && length <= 1)
|
||||||
return arg;
|
return obj;
|
||||||
var obj = new this(this.dont);
|
obj = new this(this.dont);
|
||||||
obj = obj.initialize.apply(obj, start > 0 || length < list.length
|
return obj.initialize.apply(obj, start > 0 || length < list.length
|
||||||
? Array.prototype.slice.call(list, start, start + length)
|
? Array.prototype.slice.call(list, start, start + length)
|
||||||
: list) || obj;
|
: list) || obj;
|
||||||
return obj;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
readAll: function(list, start) {
|
readAll: function(list, start) {
|
||||||
|
|
Loading…
Reference in a new issue