
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
static-type-js
Advanced tools
Type checking support for javascript
/// var Parent = Type.create([type definition], [prototype]);
/// var Child = Parent.inherit([type definition], [prototype]);
var AdminUser, Group, User;
Group = Type.create({
_group: Type.STRING,
invoked: Type.STRING
}, {
_invoke: function(group) {
this.invoked = group;
},
_construct: function(group) {
this._group = group;
},
setGroup: function(value) {
this._group = value;
},
getGroup: function() {
return this._group;
}
});
AdminUser = Group.inherit({
username: Type.STIRNG,
date: Type.DATE
},{
_construct: function(username) {
this.username = username;
this.date = new Date;
this._super('admin'); /// this will override group because parent is group
},
setUser: function(value) {
this.username = value;
}
});
User = AdminUser.inherit({
username: Type.STIRNG,
date: Type.DATE
},{
_construct: function(username) {
this.username = username;
this.date = new Date;
this._super('test'); // this will override username to test because parent is AdminUser
this.setGroup('user'); // this will set group to user
},
setPassword: function(value) {
// this is not allowed all members must be defined at initialization proces (in _construct)
this.password = value;
}
});
var user = new User('igor');
user.username = 1; // throws type error because initial value is string
user.date = new RegExp; // throw type error because initial value is date
user.date = new Date; // is allowed because is correct type
user.date = null; // its allowed because all members are allowed to be null or undefined because of GC
user.date = 1; // re assigning values with wrong type throws type error
user.date = new Date; // re assigning initial value is allowed
User.prototype.one = 1; // Will throw type error because adding something to prototype after initialization is not allowed
User.one = 1; // Extending roots is not allowed
FAQs
Prototype inheritance and type system for js
The npm package static-type-js receives a total of 4 weekly downloads. As such, static-type-js popularity was classified as not popular.
We found that static-type-js 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
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.