monocle-ts
Advanced tools
Comparing version 0.5.3-rc to 1.0.0
@@ -16,2 +16,7 @@ # Changelog | ||
# 1.0.0 | ||
* **Breaking Change** | ||
* upgrade to `fp-ts@1.0.0` (@gcanti) | ||
# 0.5.2 | ||
@@ -18,0 +23,0 @@ |
{ | ||
"name": "monocle-ts", | ||
"version": "0.5.3-rc", | ||
"version": "1.0.0", | ||
"description": "A porting of scala monocle library to TypeScript", | ||
@@ -17,8 +17,5 @@ "files": ["lib"], | ||
"prettier --no-semi --single-quote --print-width 120 --parser typescript --write \"{src,test,examples}/**/*.ts\"", | ||
"flow-copy-definition-files": "cp src/*.js.flow lib", | ||
"flow-fix-prettier": | ||
"prettier --no-semi --single-quote --print-width 120 --parser flow --write \"{src,test,examples,exercises}/**/*.js.flow\"", | ||
"test": "npm run prettier && npm run lint && npm run typings-checker && npm run mocha", | ||
"clean": "rm -rf lib/*", | ||
"build": "npm run clean && tsc && npm run flow-copy-definition-files", | ||
"build": "npm run clean && tsc", | ||
"docs-fix-prettier": "prettier --no-semi --single-quote --print-width 120 --parser markdown --write \"README.md\"", | ||
@@ -38,3 +35,3 @@ "docs": "doctoc README.md && npm run docs-fix-prettier" | ||
"dependencies": { | ||
"fp-ts": "^1.0.0-rc" | ||
"fp-ts": "^1.0.0" | ||
}, | ||
@@ -41,0 +38,0 @@ "devDependencies": { |
@@ -1280,2 +1280,34 @@ # Motivation | ||
Example: reversing strings in a nested array | ||
```ts | ||
import { Lens, fromTraversable } from 'monocle-ts' | ||
import { array } from 'fp-ts/lib/Array' | ||
interface Tweet { | ||
text: string | ||
} | ||
interface Tweets { | ||
tweets: Tweet[] | ||
} | ||
const tweetsLens = Lens.fromProp<Tweets, 'tweets'>('tweets') | ||
const tweetTextLens = Lens.fromProp<Tweet, 'text'>('text') | ||
const tweetTraversal = fromTraversable(array)<Tweet>() | ||
const composedTraversal = tweetsLens.composeTraversal(tweetTraversal).composeLens(tweetTextLens) | ||
const tweet1: Tweet = { text: 'hello world' } | ||
const tweet2: Tweet = { text: 'foobar' } | ||
const model: Tweets = { tweets: [tweet1, tweet2] } | ||
const newModel = composedTraversal.modify(text => | ||
text | ||
.split('') | ||
.reverse() | ||
.join('') | ||
)(model) | ||
// { tweets: [ { text: 'dlrow olleh' }, { text: 'raboof' } ] } | ||
``` | ||
# fromFoldable | ||
@@ -1282,0 +1314,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
1319
84808
7
Updatedfp-ts@^1.0.0