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

Prototype extensions.

  • 0.2.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

Rubyisms

Ruby style ES5 prototype extensions

Info

A highly experimental set of prototype extensions for native types in ES5 JavaScript.

Install

Using npm.

npm install rubyisms

Documentation

Full list of methods here.

Issues

Object.prototype

Rubyisms defines properties on Object.prototype. A side effect is the creation of globally scoped constants. The following should be treated as reserved keywords in the global scope, and are not writable.

  • array
  • bool
  • func
  • numeric
  • object
  • size
  • type

Everything created will contain these as prototype properties. To override these properties on objects you must define them during construction, or explicitly define them with Object.defineProperty.

No good.

var o = {};
o.size = 5 // Will not write
o.size // 0

function Constructor () {
	this.size = 5; // Will not write
}

new Constructor().size // 0

Better.

var o = {size: 5};
o.size // 5

function Constructor () {
	Object.defineProperty(this, 'size', {
		value: 5,
		writable: true
	});
}

new Constructor().size // 5

.type

Return values from calling .type on the global object will differ. In V8 (Chrome, Node), the return string is 'global', whereas in other browsers it is 'window'.

FAQs

Package last updated on 13 Jun 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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