
Product
Introducing Webhook Events for Pull Request Scans
Add real-time Socket webhook events to your workflows to automatically receive pull request scan results and security alerts in real time.
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
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.
Product
Add real-time Socket webhook events to your workflows to automatically receive pull request scan results and security alerts in real time.
Research
The Socket Threat Research Team uncovered malicious NuGet packages typosquatting the popular Nethereum project to steal wallet keys.
Product
A single platform for static analysis, secrets detection, container scanning, and CVE checks—built on trusted open source tools, ready to run out of the box.