Skip to content

Commit 4fc4adb

Browse files
authored
Initial commit
0 parents  commit 4fc4adb

File tree

10 files changed

+164
-0
lines changed

10 files changed

+164
-0
lines changed

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
indent_style = tab
5+
end_of_line = lf
6+
charset = utf-8
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true
9+
10+
[*.yml]
11+
indent_style = space
12+
indent_size = 2

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

.github/workflows/main.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: CI
2+
on:
3+
- push
4+
- pull_request
5+
jobs:
6+
test:
7+
name: Node.js ${{ matrix.node-version }}
8+
runs-on: ubuntu-latest
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
node-version:
13+
- 20
14+
- 18
15+
- 16
16+
steps:
17+
- uses: actions/checkout@v3
18+
- uses: actions/setup-node@v3
19+
with:
20+
node-version: ${{ matrix.node-version }}
21+
- run: npm install
22+
- run: npm test

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
yarn.lock

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false

index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export default function unicornFun(input, {postfix = 'rainbows'} = {}) {
2+
if (typeof input !== 'string') {
3+
throw new TypeError(`Expected a string, got ${typeof input}`);
4+
}
5+
6+
return `${input} & ${postfix}`;
7+
}

license

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
MIT License
2+
3+
Copyright (c) Your Name <[email protected]> (https://yourwebsite.com)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

package.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"name": "unicorn-fun",
3+
"version": "0.0.0",
4+
"description": "My awesome module",
5+
"license": "MIT",
6+
"repository": "YOUR-GITHUB-USERNAME/unicorn-fun",
7+
"author": {
8+
"name": "YOUR NAME",
9+
"email": "YOUR EMAIL",
10+
"url": "YOUR WEBSITE"
11+
},
12+
"type": "module",
13+
"exports": "./index.js",
14+
"engines": {
15+
"node": ">=16"
16+
},
17+
"scripts": {
18+
"test": "xo && ava"
19+
},
20+
"files": [
21+
"index.js"
22+
],
23+
"keywords": [
24+
"unicorn",
25+
"fun"
26+
],
27+
"dependencies": {},
28+
"devDependencies": {
29+
"ava": "^5.3.0",
30+
"xo": "^0.54.2"
31+
}
32+
}

readme.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# node-module-boilerplate
2+
3+
> Boilerplate to kickstart creating a Node.js module
4+
5+
This is what I use for [my own modules](https://www.npmjs.com/~sindresorhus).
6+
7+
Also check out [`node-cli-boilerplate`](https://github.com/sindresorhus/node-cli-boilerplate).
8+
9+
## Getting started
10+
11+
**Click the "Use this template" button.**
12+
13+
Alternatively, create a new directory and then run:
14+
15+
```sh
16+
curl -fsSL https://github.com/sindresorhus/node-module-boilerplate/archive/main.tar.gz | tar -xz --strip-components=1
17+
```
18+
19+
There's also a [Yeoman generator](https://github.com/sindresorhus/generator-nm).
20+
21+
---
22+
23+
**Remove everything from here and above**
24+
25+
---
26+
27+
# unicorn-fun
28+
29+
> My awesome module
30+
31+
## Install
32+
33+
```sh
34+
npm install unicorn-fun
35+
```
36+
37+
## Usage
38+
39+
```js
40+
import unicornFun from 'unicorn-fun';
41+
42+
unicornFun('unicorns');
43+
//=> 'unicorns & rainbows'
44+
```
45+
46+
## API
47+
48+
### unicornFun(input, options?)
49+
50+
#### input
51+
52+
Type: `string`
53+
54+
Lorem ipsum.
55+
56+
#### options
57+
58+
Type: `object`
59+
60+
##### postfix
61+
62+
Type: `string`\
63+
Default: `'rainbows'`
64+
65+
Lorem ipsum.

test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import test from 'ava';
2+
import unicornFun from './index.js';
3+
4+
test('main', t => {
5+
t.throws(() => {
6+
unicornFun(123);
7+
}, {
8+
instanceOf: TypeError,
9+
message: 'Expected a string, got number',
10+
});
11+
12+
t.is(unicornFun('unicorns'), 'unicorns & rainbows');
13+
});

0 commit comments

Comments
 (0)