Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
State management with error handling and reactive cache done right.
Alternative standalone implementation of eigenmethod mol_atom.
Install npm install --save lom_atom
import {mem} from 'lom_atom'
class Todo {
id = Math.random()
@mem title = ''
@mem finished = false
}
One decorator for all cases.
class TodoList {
@mem todos = []
@mem get unfinishedTodos() {
return this.todos.filter((todo) => !todo.finished)
}
}
Like mobx, unfinishedTodos is updated automatically when a todo changed.
Like mobx reaction produces a side effect for making network requests, etc. But side effects in lom are simpler.
class TodoList {
@mem set todos(todos: Todo | Error) {}
@mem get todos() {
// Side effect, cached in mem
fetch('/todos')
.then((todos) => {
this.todos = todos
})
.catch(e => this.todos = e)
throw new mem.Wait()
}
@mem get unfinishedTodos() {
return this.todos.filter((todo) => !todo.finished)
}
}
class Listener {
_list = new TodoList()
@mem listen() {
try {
console.log('total todos:', this._list.todos.length)
console.log('unfinished todos:', this._list.unfinishedTodos.length)
} catch (e) {
if (e instanceof mem.Wait) {
console.log('loading...')
} else {
console.error('error', e.message)
}
}
}
}
const listener = new Listener()
listener.listen()
Killer feature, grabbed from mol_atom. We can reset cache on get or obviously set cache value, using magic force property.
import {force, mem} from 'lom_atom'
class TodoList {
@force force: TodoList
@mem set todos(todos: Todo | Error) {
console.log('set handler')
}
@mem get todos() {
console.log('get handler')
return [someTodo]
}
}
const list = new TodoList()
list.todos = [someTodo] // console: set handler
list.todos = [someTodo] // someTodo already set - no handler call
list.force.todos = [someTodo] // force, console: set handler
list.todos // console: get handler
list.todos // return cached value
list.force.todos // console: get handler
Basic dictionary support. See eigenmethod mol_mem.
class TodoList {
@mem.key todo(id: string, next?: Todo, force?: boolean): Todo {
if (next === undefined) {
return {}
}
return next
}
}
const list = new TodoList()
list.todo('1', {id: 1, title: 'Todo 1'}) // set todo
list.todo('1') // get todo
1.0.9 (2017-08-14)
<a name="1.0.8"></a>
FAQs
Alternative implementation of eigenmethod mol_atom state management library
The npm package lom_atom receives a total of 1 weekly downloads. As such, lom_atom popularity was classified as not popular.
We found that lom_atom 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.