Socket
Socket
Sign inDemoInstall

@libre/atom

Package Overview
Dependencies
0
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.1 to 1.0.2

dist/index.esm.js

39

package.json

@@ -17,4 +17,2 @@ {

"devDependencies": {
"@babel/core": "^7.1.6",
"@babel/preset-env": "^7.1.6",
"@commitlint/cli": "^7.2.1",

@@ -25,17 +23,16 @@ "@commitlint/config-conventional": "^7.1.2",

"@types/node": "^10.12.9",
"@types/ramda": "^0.25.41",
"@types/react": "^16.7.6",
"@types/react-dom": "^16.0.9",
"@types/react-test-renderer": "^16.0.3",
"@types/webpack": "^4.4.19",
"babel-loader": "^8.0.4",
"codecov": "^3.1.0",
"commitizen": "^2.10.1",
"cz-conventional-changelog": "^2.1.0",
"fork-ts-checker-webpack-plugin": "^0.4.15",
"husky": "^1.1.4",
"jest": "^23.6.0",
"peer-deps-externals-webpack-plugin": "^1.0.4",
"prettier": "^1.15.2",
"rimraf": "^2.6.2",
"rollup": "^0.67.4",
"rollup-plugin-commonjs": "^9.2.0",
"rollup-plugin-json": "^3.1.0",
"rollup-plugin-node-resolve": "^4.0.0",
"rollup-plugin-sourcemaps": "^0.4.2",
"rollup-plugin-typescript2": "^0.18.0",
"rollup-plugin-uglify": "^6.0.0",
"semantic-release": "^15.6.3",

@@ -45,12 +42,6 @@ "source-map-support": "^0.5.6",

"ts-jest": "^23.10.4",
"ts-loader": "^5.3.0",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.16.0",
"typedoc": "^0.13.0",
"typedoc-twilio-theme": "^1.0.0",
"typescript": "^3.1.6",
"uglifyjs-webpack-plugin": "^1.2.7",
"webpack": "^4.25.1",
"webpack-cli": "^3.1.2",
"webpack-node-externals": "^1.7.2"
"typescript": "^3.1.6"
},

@@ -79,3 +70,4 @@ "files": [

"license": "MIT",
"main": "dist/index.js",
"main": "dist/index.umd.js",
"module": "dist/index.esm.js",
"name": "@libre/atom",

@@ -87,6 +79,5 @@ "repository": {

"scripts": {
"build": "npm run clean && NODE_ENV=production webpack",
"build:dev": "npm run clean && webpack",
"build": "rollup -c rollup.config.ts",
"build:dev": "npm run prebuild && webpack",
"build:docs": "rimraf docs && typedoc --options typedoc.js src",
"clean": "rimraf dist",
"git:commit": "npx git-cz",

@@ -96,2 +87,3 @@ "dev": "npm run test -- --watch",

"lint:fix": "tslint --project --fix",
"prebuild": "rimraf dist",
"semantic-release": "semantic-release",

@@ -103,4 +95,5 @@ "test": "jest --env=jsdom",

"sideEffects": false,
"types": "dist/index.d.ts",
"version": "1.0.1"
"types": "dist/types/index.d.ts",
"unpkg": "https://unpkg.com/@libre/atom",
"version": "1.0.2"
}

@@ -15,2 +15,4 @@ <div>

<div style="heigth:40px;">&nbsp;</div>
[![TypeScript](https://badges.frapsoft.com/typescript/version/typescript-next.svg?v=101)](https://github.com/ellerbrock/typescript-badges/)

@@ -31,2 +33,7 @@ [![npm (scoped)](https://img.shields.io/npm/v/@libre/atom.svg)](https://www.npmjs.com/package/@libre/atom)

`@libre/atom` provides a data type called `Atom`s and a few functions for working with `Atom`s. It is heavily inspired by `atom`s in Clojure(Script). While the full power of Clojure `atom`s cannot be experienced in JavaScript's single-threaded runtime, `Atom`s do still offer similar benefits due to the highly asynchronous and event-driven nature of JavaScript.
Atoms provide a predictable way to manage state shared by multiple components of a
program as that state changes over time. They are particularly useful in the functional and reactive programming paradigms, where most components of a program are pure functions operating on immutable data. `Atoms` provide a controlled mechanism for mutability that lets multiple components access and update the same value without risking mutating another component's reference to it in the middle of some process or asynchronous operation.
### Put your state in an `Atom`:

@@ -58,3 +65,6 @@

```ts
function swap<S>(atom: Atom<S>, updateFn: (state: S) => S): void;
function swap<S>(
atom: Atom<S>,
updateFn: (state: DeepImmutable<S>) => S
): void;
```

@@ -79,12 +89,34 @@

Take notice that our `updateFn` is [spread](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax)ing the old state onto a new object before overriding `color`. This is an easy way to obey the rules of `updateFn`.
> **Note:** Our `updateFn` is [spread](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_syntax)ing the old state onto a new object before overriding `color`. This is an easy way to obey the rules of `updateFn`. If manually spreading values seems tedious, there are many libraries that offer convenient functions for operating on JS data structures in an immutable manner, e.g. see [ramda](https://ramdajs.com/), [sanctuary](https://sanctuary.js.org/), [crocks](https://evilsoft.github.io/crocks/docs/), or (for the wizards among us) [fp-ts](https://gcanti.github.io/fp-ts/).
## Installation
`react-atom` has zero `dependencies`!
**NPM**: `npm install --save @libre/atom`
**Yarn**: `yarn add @libre/atom`
**CDN**: `<script src="https://unpkg.com/@libre/atom" />`
- Exposed on the global object, like so: `window["@libre/atom"]`
## Usage
**ES6 `import`**
```js
import { Atom, deref, set, swap } from "@libre/atom";
```
npm i -S @libre/atom
**CommonJS `require`**
```js
const { Atom, deref, set, swap } = require("@libre/atom");
```
**Web `<script />` tag**
```js
const { Atom, deref, set, swap } = window["@libre/atom"];
```
## Documentation

@@ -91,0 +123,0 @@

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc