Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Modify JS constructor functions to be callable without `new`.
JavaScript HTML
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
.editorconfig
.gitignore
LICENSE
README.md
newless.js
package.json
test.html
test.js
test_helper_node.js

README.md

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-2015 Rob Brackett and licensed under the BSD license. The full license text is in the LICENSE file.

Something went wrong with that request. Please try again.