Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Structs inspired from Golang
newStruct = require('new-struct')
Animal = newStruct({
name: '',
type: '',
age: 0,
run: run
})
function run (animal) {
console.log('%s is running', animal.name)
}
dongdong = Animal('dongdong', 'cat', 4)
blackbear = Animal('blackbear', 'cat', 3)
dongdong.run()
// => dongdong is running
blackbear.run()
// => blackbear is running
$ npm install new-struct
You can pass the values as an object, too;
dongdong = Animal({ type: 'cat', foobar: 'dfjh' })
Methods can also be defined later;
Animal.method('jump', function(animal){
console.log('%s is jumping!!', animal.name)
})
To extend an existing struct:
Cat = Animal.extend({
type: 'cat',
grrr: grrr
})
function grrr(cat) {
console.log('grrrrrr')
}
dongdong = Cat('dongdong', 2) // notice how 'type' property got eleminated from parameter order.
To define a constructor method:
Animal = newStruct({
construct: construct,
name: '',
type: '',
age: 0,
run: run
})
function construct (animal) {
animal.log = console.log
animal.log('%s just born!', animal.name)
}
dondong = Animal('dongdong', 'cat')
// => dongdong just born
FAQs
This package name is not currently in use, but was formerly occupied by a popular package. To avoid malicious use, npm is hanging on to the package name, but loosely, and we'll probably give it to you if you want it.
The npm package new-struct receives a total of 2 weekly downloads. As such, new-struct popularity was classified as not popular.
We found that new-struct 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
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.