Skip to content
This repository was archived by the owner on Jul 17, 2020. It is now read-only.

Commit 6a99c26

Browse files
author
Zirak
committed
added Array.from as a [].slice.call alias
1 parent 3c45680 commit 6a99c26

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

source/plugins/roomPermissions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function giveVoice ( id, cb ) {
3737
});
3838

3939
function finish () {
40-
var args = [].slice.call( arguments );
40+
var args = Array.from( arguments );
4141
args.unshift( id );
4242

4343
delete muted[ id ];

source/plugins/substitution.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function substitute ( msg ) {
4848
}
4949

5050
function get_matching_message ( re, onlyBefore ) {
51-
var messages = [].slice.call(
51+
var messages = Array.from(
5252
document.getElementsByClassName('content') ).reverse();
5353
return messages.first( matches );
5454

source/util.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,16 @@ Object.TruthMap = function ( props ) {
2626
}
2727
};
2828

29+
//turns a pseudo-array (like arguments) into a real array
30+
Array.from = function ( arrayLike, start ) {
31+
return [].slice.call( arrayLike, start );
32+
};
33+
2934
//SO chat uses an unfiltered for...in to iterate over an array somewhere, so
3035
// that I have to use Object.defineProperty to make these non-enumerable
3136
Object.defineProperty( Array.prototype, 'invoke', {
3237
value : function ( funName ) {
33-
var args = [].slice.call( arguments, 1 );
38+
var args = Array.from( arguments, 1 );
3439

3540
return this.map( invoke );
3641

@@ -151,7 +156,7 @@ Function.prototype.memoizeAsync = function ( hasher ) {
151156
hasher = hasher || function (x) { return x; };
152157

153158
return function memoized () {
154-
var args = [].slice.call( arguments ),
159+
var args = Array.from( arguments ),
155160
cb = args.pop(), //HEAVY assumption that cb is always passed last
156161
hash = hasher.apply( null, arguments );
157162

0 commit comments

Comments
 (0)