Skip to content

Commit 1816eae

Browse files
authored
feat: create fns package (diegomura#1838)
1 parent ecc066f commit 1816eae

36 files changed

+171
-11
lines changed

β€Ž.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lib

β€ŽREADME.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<p align="center">
2+
<img src="https://user-images.githubusercontent.com/5600341/27505816-c8bc37aa-587f-11e7-9a86-08a2d081a8b9.png" height="280px">
3+
</p>
4+
5+
# @react-pdf/fns
6+
7+
> React-pdf helper functions
8+
9+
## How to install
10+
```sh
11+
yarn add @react-pdf/fns
12+
```

β€Žbabel.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = { extends: '../../babel.config.js' };

β€Žjest.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
testRegex: 'tests/.*?(test)\\.js$',
3+
};

β€Žpackage.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "@react-pdf/fns",
3+
"version": "0.0.0",
4+
"license": "MIT",
5+
"description": "React-pdf helper functions",
6+
"author": "Diego Muracciole <[email protected]>",
7+
"homepage": "https://github.com/diegomura/react-pdf#readme",
8+
"main": "lib/index.js",
9+
"repository": {
10+
"type": "git",
11+
"url": "https://github.com/diegomura/react-pdf.git",
12+
"directory": "packages/fns"
13+
},
14+
"scripts": {
15+
"test": "jest",
16+
"build": "rimraf ./lib && babel src --out-dir lib",
17+
"watch": "rimraf ./lib && babel src --out-dir lib --watch"
18+
},
19+
"files": [
20+
"lib"
21+
]
22+
}

β€Žadjust.js renamed to β€Žsrc/adjust.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
/**
2+
* Applies a function to the value at the given index of an array
3+
4+
* @param {number} index
5+
* @param {function} fn
6+
* @param {array} collection
7+
* @returns copy of the array with the element at the given index replaced with the result of the function application.
8+
*/
19
const adjust = (index, fn, collection) => {
210
if (index >= 0 && index >= collection.length) return collection;
311
if (index < 0 && Math.abs(index) > collection.length) return collection;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
Β (0)