Socket
Socket
Sign inDemoInstall

newless

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    newless

Modify constructors to function without `new`.


Version published
Weekly downloads
676
decreased by-6.5%
Maintainers
1
Install size
6.98 kB
Created
Weekly downloads
 

Readme

Source

Newless

Newless is a super-simple JavaScript library that allows you to modify or create constructor functions that don't need to be called with new. This makes your code more safe and allows constructors to be used in more functional contexts (such as Array.map).

You can use it on a constructor while creating it:

var MyObject = newless(function(something) {
  this.setSomething(something);
});

MyObject.prototype.setSomething = function(value) {
  this.something = value;
};

var instance = MyObject("Hello");
instance.something; // "Hello"

You can also use it with existing constructors from other libraries without disrupting them:

var Map = newless(google.maps.Map);
var map = Map(document.getElementById("map-canvas"), options);
// or
var User = newless(Backbone.Model.extend({...}));
var user = User({name: "Jennifer"});

License

Newless is open source software. It is (c) 2013 Rob Brackett and licensed under the BSD license. The full license text is in the LICENSE file.

Keywords

FAQs

Last updated on 28 Apr 2013

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc