Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rubyisms

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rubyisms - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

2

package.json
{
"name": "rubyisms",
"version": "0.1.5",
"version": "0.1.6",
"description": "Prototype extensions.",

@@ -5,0 +5,0 @@ "main": "rubyisms.js",

@@ -5,3 +5,3 @@ // Colin 'Oka' Hall-Coates

;(function () {
;(function ($) {
'use strict';

@@ -14,72 +14,87 @@

NP = Number.prototype;
function $(g, s) {return {get: g, set: s};}
// Getters
def(SP, {
capitalize: {
get: function () {
return this.substring(0, 1).toUpperCase() + this.substring(1);
}
},
chars: {
get: function () {
return this.split('');
}
},
chr: {
get: function () {
return this.substring(0, 1);
}
},
downcase: {
get: function () {
return this.toLowerCase();
}
},
empty: {
get: function () {
return this.length < 1;
}
},
reverse: {
get: function () {
var r = '', i = this.length - 1, e;
for (e = 0; i >= e; i--) r += this[i];
return r;
}
},
upcase: {
get: function () {
return this.toUpperCase();
}
}
capitalize: $(function () {
return this.substring(0, 1).toUpperCase() + this.substring(1);
}),
chars: $(function () {
return this.split('');
}),
chr: $(function () {
return this.substring(0, 1);
}),
downcase: $(function () {
return this.toLowerCase();
}),
empty: $(function () {
return this.length < 1;
}),
reverse: $(function () {
var r = '', i = this.length - 1, e;
for (e = 0; i >= e; i--) r += this[i];
return r;
}),
upcase: $(function () {
return this.toUpperCase();
})
});
def(AP, {
clear: {
get: function () {
while (this.length > 0) this.pop();
return this;
}
},
compact: {
get: function () {
return this.filter(function (e) {
return (typeof e !== 'undefined');
});
}
},
uniq: {
get: function () {
var c = {};
return this.filter(function (e) {
return (c.hasOwnProperty(e) ? false : c[e] = true);
});
}
}
clear: $(function () {
while (this.length > 0) this.pop(); return this;
}),
compact: $(function () {
return this.filter(function (e) {
return (typeof e !== 'undefined');
});
}),
uniq: $(function () {
var c = {};
return this.filter(function (e) {
return (c.hasOwnProperty(e) ? false : c[e] = true);
});
}),
});
def(OP, {});
def(NP, {});
def(OP, {
array: $(function () {
return Array.isArray(this);
}),
bool: $(function () {
return typeof this === 'boolean';
}),
numeric: $(function () {
return typeof this === 'number' && this === this;
}),
object: $(function () {
return !Array.isArray(this) && typeof this === 'object';
}),
size: $(function () {
if (Array.isArray(this) || typeof this === 'string') return this.length;
else if (typeof this === 'object') return Object.keys(this).length;
}),
string: $(function () {
return typeof this === 'string';
})
});
// Methods
def(NP, {
abs: $(function () {
return Math.abs(this);
}),
finite: $(function () {
return isFinite(this);
}),
floor: $(function () {
return Math.floor(this);
}),
integer: $(function () {
return this.toFixed() == this;
}),
polar: $(function () {
return [Math.abs(this), (this > 0 ? 0 : Math.PI)];
})
});

@@ -145,3 +160,6 @@ var _String = {

var _Number = {
_p: NP
_p: NP,
eql: function (o) {
return this === o;
}
};

@@ -148,0 +166,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc