mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -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) {
|
||||
var start = start || 0,
|
||||
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 (arg instanceof this
|
||||
|| this.prototype._readNull && arg == null && length <= 1)
|
||||
return arg;
|
||||
var obj = new this(this.dont);
|
||||
obj = obj.initialize.apply(obj, start > 0 || length < list.length
|
||||
if (obj instanceof this
|
||||
|| this.prototype._readNull && obj == null && length <= 1)
|
||||
return obj;
|
||||
obj = new this(this.dont);
|
||||
return obj.initialize.apply(obj, start > 0 || length < list.length
|
||||
? Array.prototype.slice.call(list, start, start + length)
|
||||
: list) || obj;
|
||||
return obj;
|
||||
},
|
||||
|
||||
readAll: function(list, start) {
|
||||
|
|
Loading…
Reference in a new issue