-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
87 changed files
with
246 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
'@react-pdf/fns': major | ||
'@react-pdf/layout': patch | ||
'@react-pdf/render': patch | ||
'@react-pdf/stylesheet': patch | ||
'@react-pdf/textkit': patch | ||
--- | ||
|
||
feat: create fns package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<p align="center"> | ||
<img src="https://user-images.githubusercontent.com/5600341/27505816-c8bc37aa-587f-11e7-9a86-08a2d081a8b9.png" height="280px"> | ||
</p> | ||
|
||
# @react-pdf/fns | ||
|
||
> React-pdf helper functions | ||
## How to install | ||
```sh | ||
yarn add @react-pdf/fns | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = { extends: '../../babel.config.js' }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
testRegex: 'tests/.*?(test)\\.js$', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "@react-pdf/fns", | ||
"version": "0.0.0", | ||
"license": "MIT", | ||
"description": "React-pdf helper functions", | ||
"author": "Diego Muracciole <diegomuracciole@gmail.com>", | ||
"homepage": "https://github.com/diegomura/react-pdf#readme", | ||
"main": "lib/index.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/diegomura/react-pdf.git", | ||
"directory": "packages/fns" | ||
}, | ||
"scripts": { | ||
"test": "jest", | ||
"build": "rimraf ./lib && babel src --out-dir lib", | ||
"watch": "rimraf ./lib && babel src --out-dir lib --watch" | ||
}, | ||
"files": [ | ||
"lib" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export { default as adjust } from './adjust'; | ||
export { default as asyncCompose } from './asyncCompose'; | ||
export { default as capitalize } from './capitalize'; | ||
export { default as castArray } from './castArray'; | ||
export { default as compose } from './compose'; | ||
export { default as dropLast } from './dropLast'; | ||
export { default as evolve } from './evolve'; | ||
export { default as get } from './get'; | ||
export { default as isNil } from './isNil'; | ||
export { default as last } from './last'; | ||
export { default as mapValues } from './mapValues'; | ||
export { default as matchPercent } from './matchPercent'; | ||
export { default as omit } from './omit'; | ||
export { default as pick } from './pick'; | ||
export { default as reverse } from './reverse'; | ||
export { default as upperFirst } from './upperFirst'; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
packages/fns/adjust.test.js → packages/fns/tests/adjust.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import adjust from './adjust'; | ||
import adjust from '../src/adjust'; | ||
|
||
const add = v => v + 1; | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
packages/fns/capitalize.test.js → packages/fns/tests/capitalize.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import castArray from '../src/castArray'; | ||
|
||
describe('castArray', () => { | ||
test('should return [undefined] for undefined', () => { | ||
expect(castArray(undefined)).toEqual([undefined]); | ||
}); | ||
|
||
test('should return [null] for null', () => { | ||
expect(castArray(null)).toEqual([null]); | ||
}); | ||
|
||
test('should cast passed value in an array', () => { | ||
expect(castArray('test')).toEqual(['test']); | ||
}); | ||
|
||
test('should return array if passed array', () => { | ||
expect(castArray(['reactpdf'])).toEqual(['reactpdf']); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import compose from '../src/compose'; | ||
|
||
describe('compose', () => { | ||
test('performs right-to-left function composition', () => { | ||
const multiply = a => b => a * b; | ||
const map = fn => collection => collection.map(fn); | ||
const f = compose(map, multiply, parseInt); | ||
|
||
expect(f('10')([1, 2, 3])).toEqual([10, 20, 30]); | ||
expect(f('10', 2)([1, 2, 3])).toEqual([2, 4, 6]); | ||
}); | ||
}); |
2 changes: 1 addition & 1 deletion
2
packages/fns/dropLast.test.js → packages/fns/tests/dropLast.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import evolve from '../src/evolve'; | ||
|
||
const add = a => b => a + b; | ||
|
||
describe('evolve', () => { | ||
test('creates a new object by evolving the `object` according to the `transformation` functions', () => { | ||
const transf = { elapsed: add(1), remaining: add(-1) }; | ||
const object = { name: 'Tomato', elapsed: 100, remaining: 1400 }; | ||
const expected = { name: 'Tomato', elapsed: 101, remaining: 1399 }; | ||
|
||
expect(evolve(transf, object)).toEqual(expected); | ||
}); | ||
|
||
test('does not invoke function if object does not contain the key', () => { | ||
const transf = { n: add(1), m: add(1) }; | ||
const object = { m: 3 }; | ||
const expected = { m: 4 }; | ||
|
||
expect(evolve(transf, object)).toEqual(expected); | ||
}); | ||
|
||
test('is not destructive', () => { | ||
const transf = { elapsed: add(1), remaining: add(-1) }; | ||
const object = { name: 'Tomato', elapsed: 100, remaining: 1400 }; | ||
const expected = { name: 'Tomato', elapsed: 100, remaining: 1400 }; | ||
|
||
evolve(transf, object); | ||
|
||
expect(object).toEqual(expected); | ||
}); | ||
|
||
test('creates a new array by evolving the `array` according to the `transformation` functions', () => { | ||
const transf = [add(1), add(-1)]; | ||
const object = [100, 1400]; | ||
const expected = [101, 1399]; | ||
|
||
expect(evolve(transf, object)).toEqual(expected); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import get from './get'; | ||
import get from '../src/get'; | ||
|
||
describe('get', () => { | ||
const deepObject = { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/fns/matchPercent.test.js → packages/fns/tests/matchPercent.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
import omit from './omit'; | ||
import omit from '../src/omit'; | ||
|
||
describe('omit', () => { | ||
const obj = { a: 1, b: 2, c: 3 }; | ||
|
||
test('copies an object omitting the listed property', () => { | ||
expect(omit('a', obj), { b: 2, c: 3 }); | ||
expect(omit('a', obj)).toEqual({ b: 2, c: 3 }); | ||
}); | ||
|
||
test('copies an object omitting the listed properties', () => { | ||
expect(omit(['a', 'c'], obj), { c: 3 }); | ||
expect(omit(['a', 'c'], obj)).toEqual({ b: 2 }); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import pick from '../src/pick'; | ||
|
||
describe('pick', () => { | ||
const obj = { a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, 1: 7 }; | ||
|
||
test('copies the named properties of an object to the new object', () => { | ||
expect(pick(['a', 'c', 'f'], obj)).toEqual({ a: 1, c: 3, f: 6 }); | ||
}); | ||
|
||
test('handles numbers as properties', () => { | ||
expect(pick([1], obj)).toEqual({ 1: 7 }); | ||
}); | ||
|
||
test('ignores properties not included', () => { | ||
expect(pick(['a', 'c', 'g'], obj)).toEqual({ a: 1, c: 3 }); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import reverse from '../src/reverse'; | ||
|
||
describe('reverse', () => { | ||
test('reverses arrays', () => { | ||
expect(reverse([])).toEqual([]); | ||
expect(reverse([1])).toEqual([1]); | ||
expect(reverse([1, 2])).toEqual([2, 1]); | ||
expect(reverse([1, 2, 3])).toEqual([3, 2, 1]); | ||
}); | ||
}); |
2 changes: 1 addition & 1 deletion
2
packages/fns/upperFirst.test.js → packages/fns/tests/upperFirst.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.