Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

prime

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prime - npm Package Compare versions

Comparing version 0.0.4-alpha to 0.0.5-alpha

2

collection/list.js

@@ -29,3 +29,3 @@ /*

each: function(method, context){
for (var i = this.length; i--;){
for (var i = 0, l = this.length; i < l; i++){
if (i in this && method.call(context, i, this[i], this) === false) break

@@ -32,0 +32,0 @@ }

{
"name": "prime",
"homepage": "https://github.com/mootools/prime",
"version": "0.0.4-alpha",
"main": "./main.js",
"version": "0.0.5-alpha",
"main": "./prime/index.js",
"description": "prime, an OOP javascript library for node and the web.",

@@ -7,0 +7,0 @@ "keywords": [

@@ -30,3 +30,3 @@ /*

var args = (arguments.length > 1) ? array.slice(arguments, 1) : []
array.forEach(events, function(event){
array.forEach(events.slice(), function(event){
event.apply(this, args)

@@ -33,0 +33,0 @@ }, this)

@@ -5,75 +5,99 @@ /*

var prime = require("../prime"),
map = require("../collection/map"),
list = require("../es5/array")
var prime = require("../prime"),
type = require("../util/type"),
string = require("../types/string"),
number = require("../types/number"),
map = require("../collection/map"),
list = require("../collection/list"),
hash = require("../collection/hash")
module.exports = function(){
var ghosts = map()
var ghosts = map()
var ghost = function(self){
var ghost = function(self){
var responders = ghosts._keys,
hashes = ghosts._values
var responders = ghosts._keys,
hashes = ghosts._values
var Ghost
var Ghost
for (var i = responders.length, responder; responder = responders[--i];) if (responder(self)){
Ghost = hashes[i].ghost
break
}
return Ghost ? new Ghost(self) : self
for (var i = responders.length, responder; responder = responders[--i];) if (responder(self)){
Ghost = hashes[i].ghost
break
}
ghost.register = function(responder, base){
return Ghost ? new Ghost(self) : self
}
if (ghosts.get(responder)) return ghost
ghost.register = function(responder, base){
var Ghost = prime({ // yes, a prime in a prime
if (ghosts.get(responder)) return ghost
mutator: function(key, method){
this.prototype[key] = function(){
return ghost(method.apply(this.valueOf(), arguments))
}
},
var Ghost = prime({ // yes, a prime in a prime
constructor: function(self){
this.valueOf = function(){
return self
}
this.toString = function(){
return self + ""
}
this.is = function(object){
return self === object
}
mutator: function(key, method){
this.prototype[key] = function(){
return ghost(method.apply(this.valueOf(), arguments))
}
},
})
var mutator = base.mutator
// override base mutator, so it automagically implements stuff in the ghost
// when base changes
base.mutator = function(key, method){
mutator.call(this, key, method)
Ghost.mutator(key, method)
constructor: function(self){
this.valueOf = function(){
return self
}
this.toString = function(){
return self + ""
}
this.is = function(object){
return self === object
}
}
Ghost.implement(base.prototype)
})
ghosts.set(responder, {base: base, ghost: Ghost, mutator: mutator})
var mutator = base.mutator
return ghost
// override base mutator, so it automagically implements stuff in the ghost
// when base changes
base.mutator = function(key, method){
mutator.call(this, key, method)
Ghost.mutator(key, method)
}
ghost.unregister = function(responder){
var hash = ghosts.remove(responder)
if (hash) hash.base.mutator = hash.mutator
return ghost
}
Ghost.implement(base.prototype)
ghosts.set(responder, {base: base, ghost: Ghost, mutator: mutator})
return ghost
}
ghost.unregister = function(responder){
var hash = ghosts.remove(responder)
if (hash) hash.base.mutator = hash.mutator
return ghost
}
// register base objects
ghost.register(function(self){
return self && (type(self) === "array" || type(self.length) === "number")
}, list)
ghost.register(function(self){
return type(self) === "object"
}, hash)
ghost.register(function(self){
return type(self) === "number"
}, number)
ghost.register(function(self){
return type(self) === "string"
}, string)
ghost.register(function(self){
return self && self.toString() == "[object Map]"
}, map)
// export ghost
module.exports = ghost

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc