Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Atomic operations
atomic lets you perform atomic operations based on keys. Additional tasks that
try to access the same key get queued up and executed when the previous task
calls done()
to indicate it has finished its operation. It's useful when you
want to perform a multiple I/O calls on databases and don't want anything else
messing with your values in-between calls.
npm install atomic
var atomic = require('atomic')()
var o = {} // here's our db
for (var i = 1; i <= 100; i++) {
// create an atomic operation on key 'foo'
atomic('foo', function (done, key, i) {
setTimeout(function () {
o[key] = i // store i in o[key]
done() // done with this task, "unlock" key
// and move to the next task in queue
}, Math.floor(Math.random() * 50)) // sometime in the future
}, i) // pass i to the arguments (closure)
}
atomic('foo', function (done, key) {
console.log(o[key])
done()
})
This creates an atomic operation on key
. The callback is called when the key
is free (other tasks have finished working on it) and you must call done()
when you're finished your operations. For convenience, the key name and extra
arguments are passed to the callback for your function to use.
FAQs
## Initialise Atomic Run the following command to initialize the project for Atomic: ``` npx atomic init ```
The npm package atomic receives a total of 473 weekly downloads. As such, atomic popularity was classified as not popular.
We found that atomic demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.