
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Simplify prototypical inheritance. This tries to provide some simple constructs for providing functionality you get with ES6 classes, such as:
Using npm:
npm install uptown --save
Using cdn:
<script src="https://unpkg.com/uptown/dist/uptown.min.js"></script>
dist/uptown.js
contains uptown and requires lodash to be loaded separately. Can be used with requirejs.dist/uptown.min.js
contains minified uptown and dependencies (lodash).Use extendify
to add the extend method to a class (note: it mutates the original class).
The extend
class method takes three options arguments:
var extendify = require('uptown').extendify;
var Original = function() {};
Original.prototype.hello = function(value) {
return 'Hello, ' + value;
}
extendify(Original);
var SubClass = Original.extend({
// Specify a constructor for the new class
constructor: function() {
// Call parent constructor
Original.apply(this, arguments);
},
hello: function(value) {
// Add exclamation point
return Original.prototype.hello.call(this, value + '!')
}
}, {
// Specify static methods and properties
staticMethod: function() {}
}, {
// Specify getters and setters for the new class
foo: {
get: function() {},
set: function() {}
}
});
New classes may also be created using the createClass
function. The createClass
function works just like .extend
.
var createClass = require('uptown').createClass;
var Foo = createClass({
constructor: function() {
this.foo = 'bar';
}
});
FAQs
Simple ways to extend prototypes
The npm package uptown receives a total of 545 weekly downloads. As such, uptown popularity was classified as not popular.
We found that uptown demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.