Greasy Fork is available in English.

ArrayEx

配列をちょっと拡張

Questo script è stato rimosso.

// ==UserScript==
// @name         ArrayEx
// @namespace    phadra
// @version      0.4
// @description  配列をちょっと拡張
// @grant        none
// @downloadURL none
// ==/UserScript==

(function() {
	// 配列拡張
	Array.prototype.first = function(i)
	{
		return this[0];
	};
	Array.prototype.last = function(i)
	{
		return this[this.length-1];
	};

	
	Array.prototype.item = function(i)
	{
		return i>=0 && i<this.length ? this[i] : null;
	};
	Array.prototype.round = function(i)
	{
		return this[i<0? 0: i>=this.length? this.length-1: i];
	};
	Array.prototype.loop = function(i)
	{
		return this[i<0? this.length-1: i>=this.length? i%(this.length-1): i];
	};
})();