Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
prime-util
Advanced tools
Your utilities for prime
npm install prime-util
Provides an alternative way to bind class methods. Stores references to bound methods internally without any manual setup and does not modify the original methods.
var bound = require("prime-util/prime/bound")
var MyPrime = prime({
mixin: [bound],
constructor: function(){
this.results = []
},
method: function(i){
this.results.push(i)
},
run: function(){
[1, 2, 3].forEach(function(this.bound('method')))
console.log(this.results) // [1, 2, 3]
}
})
Parentize makes it easier to call overridden parent methods.
var parentize = require('prime-util/prime/parentize')
var array = require('prime/array')
var A = prime({
mixin: [parentize],
a: function(){
return array.join(arguments)
}
})
var B = prime({
mixin: [parentize],
inherits: A,
a: function(){
// first argument is the parent method name, in this case 'a'
// the other parameters are passed as the parent method arguments
return this.parent('a', 'b', 'c') + ',d'
}
})
var b = new B
console.log(b) // logs "b,c,d"
Provide "setOptions" method.
var prime = require('prime')
var Options = require('prime-util/prime/options')
var A = prime({
mixin: [Options],
options: {
'a': 'aaa',
'b': 'bbb',
'c': {
'd': 'ddd',
'e': 'eee'
}
},
constructor: function(options){
this.setOptions(options)
}
})
var a = new A({'b': 'B', 'c': {'e': 'E'}})
console.log(a.options); // {'a': 'aaa', 'b': 'B', 'c': {'d': 'ddd', 'e': 'E'}}
Creates an object with key-value pairs based on the array of keywords passed in and the current content of the array.
var animals = ['Cow', 'Pig', 'Dog', 'Cat']
var sounds = ['Moo', 'Oink', 'Woof', 'Miao']
associate(sounds, animals)
// returns {'Cow': 'Moo', 'Pig': 'Oink', 'Dog': 'Woof', 'Cat': 'Miao'}
Pushes the passed element into the array if it's not already present (case and type sensitive).
include(['Cow', 'Pig', 'Dog'], 'Cat') // returns ['Cow', 'Pig', 'Dog', 'Cat']
include(['Cow', 'Pig', 'Dog'], 'Dog') // returns ['Cow', 'Pig', 'Dog']
Empties an array.
var myArray = ['old', 'data']
empty(myArray)) // myArray is now []
Returns the first defined value of the array passed in, or null.
pick(["foo", "bar"]) // "foo"
pick([null, "bar"]) // "bar"
Returns the value from an object by its path
fromPath({
food: {
fruits: {
apples: "red",
lemon: "yellow"
}
}
}, 'food.fruits.apples') // 'red'
The following modules have been removed:
mixin
property of primeFAQs
Extra Utilities using Prime
The npm package prime-util receives a total of 17 weekly downloads. As such, prime-util popularity was classified as not popular.
We found that prime-util 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
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.