Skip to content
This repository was archived by the owner on Dec 30, 2023. It is now read-only.

Commit e3b2c17

Browse files
authored
feat(packages): ✨ Add snippets related to function (#32)
1 parent ba3c67d commit e3b2c17

File tree

12 files changed

+568
-7
lines changed

12 files changed

+568
-7
lines changed

.changeset/five-suits-talk.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@terminal-nerds/snippets-function": minor
3+
---
4+
5+
✨ Added a module `schema` for function snippets.

packages/function/.depcheckrc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"ignores": ["@terminal-nerds/*-config", "tsup", "vitest"]
3+
}

packages/function/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# @terminal-nerds/snippets-function<!-- markdownlint-disable line-length list-marker-space no-duplicate-header ul-style ul-indent no-bare-urls -->

packages/function/LICENSE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/home/xeho91/Nextcloud/Projects/terminal-nerds/snippets/LICENSE.md

packages/function/README.md

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
# @terminal-nerds/snippets-function
2+
3+
![package version badge]
4+
[![size badge]][size url]
5+
[![dependencies badge]][dependencies url]
6+
7+
➡️ **This package wraps all available modules with snippets related to [function]**
8+
— part of the [terminal-nerds/snippets] project.
9+
10+
[function]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function
11+
[terminal-nerds/snippets]: https://github.com/terminal-nerds/snippets
12+
[package version badge]: https://img.shields.io/npm/v/@terminal-nerds/snippets-function/latest?style=for-the-badge&logo=npm
13+
[dependencies badge]: https://img.shields.io/librariesio/release/npm/@terminal-nerds/snippets-function?style=for-the-badge
14+
[dependencies url]: https://libraries.io/npm/@terminal-nerds%2snippets-function
15+
[size badge]: https://img.shields.io/bundlephobia/minzip/@terminal-nerds/snippets-function?style=for-the-badge&label=size
16+
[size url]: https://packagephobia.com/result?p=@terminal-nerds/snippets-function
17+
18+
## Modules included
19+
20+
[![documentation badge]][documentation url]
21+
22+
[documentation badge]: https://img.shields.io/static/v1?color=informational&style=for-the-badge&label=documentation&message=jsdocs.io
23+
[documentation url]: https://jsdocs.io/package/@terminal-nerds/snippets-function
24+
25+
<!-- prettier-sort-markdown-table -->
26+
27+
| Name | Size |
28+
| -------------------------------------------- | ----------------------------------------------------- |
29+
| [`@terminal-nerds/snippets-function/schema`] | ![schema size gzip badge] ![schema size brotli badge] |
30+
31+
<!-- prettier-ignore-start -->
32+
<!-- MODULES LINKS -->
33+
[`@terminal-nerds/snippets-function/schema`]: https://github.com/terminal-nerds/snippets/blob/main/packages/function/source/schema/schema.ts
34+
[schema size gzip badge]: https://badgen.net/badgesize/gzip/file-url/unpkg.com/@terminal-nerds/snippets-function/dist/schema/schema.js?label=gzip
35+
[schema size brotli badge]: https://badgen.net/badgesize/brotli/file-url/unpkg.com/@terminal-nerds/snippets-function/dist/schema/schema.js?label=brotli
36+
<!-- prettier-ignore-end -->
37+
38+
---
39+
40+
## Prerequisites & usage
41+
42+
### Optional
43+
44+
[![supported typescript version badge]][typescript]
45+
![types badge]
46+
47+
[typescript]: https://typescriptlang.org/
48+
[typescript icon]: https://api.iconify.design/logos/typescript-icon.svg
49+
[supported typescript version badge]: https://img.shields.io/github/package-json/dependency-version/terminal-nerds/snippets/peer/typescript?filename=packages%2Ftypescript%2Fpackage.json&logo=typescript&style=for-the-badge&label=typescript
50+
[types badge]: https://img.shields.io/npm/types/@terminal-nerds/snippets-function?style=for-the-badge&logo=typescript
51+
52+
If you are using ![typescript icon] [TypeScript],
53+
the latest version, which supports new features _(such as `satisfies`)_, is supported.
54+
55+
### Runtime environments
56+
57+
This package can be used in several runtime environments.
58+
We aim for cross-runtime compatibility and ensure proper function messages
59+
if a particular snippet cannot be run in the currently running environment.
60+
61+
#### Browsers
62+
63+
We use [browserslist] to define the minimum browsers versions supported.\
64+
Take a look at our [shared browserslist configuration] for more details.
65+
66+
[browserslist]: https://github.com/browserslist/browserslist
67+
[shared browserslist configuration]: https://github.com/terminal-nerds/configs/blob/main/packages/browserslist/source/browsers.ts
68+
69+
**Usage**:
70+
71+
```html
72+
<script type="module">
73+
import { snippet } from "https://cdn.jsdelivr.net/npm/@terminal-nerds/snippets-function";
74+
</script>
75+
```
76+
77+
---
78+
79+
#### Bun
80+
81+
We aim to support the latest version of ![bun icon] [bun].
82+
83+
**Usage**:
84+
85+
Firstly, install it:
86+
87+
```sh
88+
bun add @terminal-nerds/snippets-function
89+
```
90+
91+
And then in a particular file:
92+
93+
```js
94+
import { snippet } from "@terminal-nerds/snippets-function";
95+
```
96+
97+
[bun]: https://bun.sh/
98+
[bun icon]: https://api.iconify.design/logos/bun.svg
99+
100+
---
101+
102+
#### Deno
103+
104+
We aim to support the latest version of ![deno icon] [Deno].
105+
106+
**Usage**:
107+
108+
```ts
109+
import { snippet } from "npm:@terminal-nerds/snippets-function";
110+
```
111+
112+
[deno]: https://deno.land/
113+
[deno icon]: https://api.iconify.design/logos/deno.svg
114+
115+
---
116+
117+
#### Node.js
118+
119+
[![node.js version support badge]][node.js]
120+
121+
The latest ![node.js icon] [Node.js] LTS _(Long-Term Support)_ version is the minimum one supported.
122+
123+
> **Warning**\
124+
> **This package is written in [ES Module] _(ESM)_ type.**\
125+
> So, if you wish to use it in a project with CommonJS (CJS) type, you need to bundle this package or a particular module(s).
126+
127+
**Usage**:
128+
129+
Install it first with the Node.js package manager of your choice. In our example, we use [pnpm].
130+
131+
```sh
132+
pnpm add @terminal-nerds/snippets-function
133+
```
134+
135+
And then in a particular file:
136+
137+
```js
138+
import { snippet } from "@terminal-nerds/snippets-function";
139+
```
140+
141+
[ES Module]: https://www.freecodecamp.org/news/javascript-es-modules-and-module-bundlers
142+
[pnpm]: https://pnpm.io
143+
[node.js]: https://nodejs.org/en/
144+
[node.js icon]: https://api.iconify.design/logos/nodejs-icon.svg
145+
[node.js version support badge]: https://img.shields.io/node/v-lts/@terminal-nerds/snippets?style=for-the-badge&logo=nodedotjs
146+
147+
---
148+
149+
## Security
150+
151+
[![workflow security badge]][security policy]
152+
153+
🔐 For more information, please refer to the [Security section] at the root of
154+
the [terminal-nerds/snippets] monorepo.
155+
156+
[workflow security badge]: https://img.shields.io/github/actions/workflow/status/terminal-nerds/snippets/maintenance.yml?label=Security&logo=github&style=for-the-badge&branch=main
157+
[security section]: https://github.com/terminal-nerds/snippets#security
158+
[security policy]: https://github.com/terminal-nerds/snippets/security/policy
159+
160+
---
161+
162+
## License
163+
164+
[![license badge]][license]
165+
166+
⚖️ For more information, please refer to the [License section] at the root of the [terminal-nerds/snippets] monorepo.
167+
168+
[license]: https://github.com/terminal-nerds/snippets/blob/main/LICENSE.md
169+
[license badge]: https://img.shields.io/github/license/terminal-nerds/snippets?style=for-the-badge
170+
[license section]: https://github.com/terminal-nerds/snippets#License
171+
172+
### Contributing
173+
174+
[![contributors badge]][contributors url]
175+
176+
🤝 **Contributions of any kind are welcome!**
177+
178+
Please refer to the monorepo _([terminal-nerds/snippets])_ project's [CONTRIBUTING file] for more information
179+
if you wish to get involved.
180+
181+
[contributing file]: https://github.com/terminal-nerds/snippets/blob/main/.github/CONTRIBUTING.md
182+
[contributors badge]: https://img.shields.io/github/contributors/terminal-nerds/snippets?style=for-the-badge
183+
[contributors url]: https://github.com/terminal-nerds/snippets#contributors
184+
185+
### Author
186+
187+
🎉 The idea of this project was initiated by [xeho91]. However, it's the [contributors] who matter the most.
188+
189+
[contributors]: https://github.com/terminal-nerds/snippets/blob/main/README.md#project-contributors
190+
[xeho91]: https://github.com/xeho91

packages/function/package.json

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
{
2+
"$schema": "https://json.schemastore.org/package",
3+
"type": "module",
4+
"name": "@terminal-nerds/snippets-function",
5+
"version": "0.0.0",
6+
"description": "@terminal-nerds reusable snippets for functions.",
7+
"keywords": [
8+
"snippets",
9+
"typescript",
10+
"function"
11+
],
12+
"license": "MIT",
13+
"author": {
14+
"name": "Mateusz Kadlubowski",
15+
"email": "[email protected]",
16+
"url": "https://xeho91.com"
17+
},
18+
"homepage": "https://github.com/terminal-nerds/snippets",
19+
"repository": {
20+
"type": "git",
21+
"url": "https://github.com/terminal-nerds/snippets.git",
22+
"directory": "packages/function"
23+
},
24+
"bugs": "https://github.com/terminal-nerds/snippets/issues",
25+
"engines": {
26+
"node": ">=18"
27+
},
28+
"exports": {
29+
".": {
30+
"types": "./dist/main.d.ts",
31+
"import": "./dist/main.js"
32+
},
33+
"./*": {
34+
"types": "./dist/*/*.d.ts",
35+
"import": "./dist/*/*.js"
36+
}
37+
},
38+
"files": [
39+
"dist/"
40+
],
41+
"scripts": {
42+
"build": "tsup",
43+
"clean": "concurrently \"pnpm:clean:*\" --group --timings",
44+
"clean:build": "del \"./dist\"",
45+
"clean:cache": "del \"./node_modules/.cache\"",
46+
"clean:test": "del \"./coverage\"",
47+
"dev:test": "vitest watch --ui",
48+
"dev:pkg": "tsup --watch",
49+
"fix": "concurrently \"pnpm:fix:*\" --group --timings",
50+
"fix:format": "pretty-quick --branch main --pattern \"packages/function/**/*\" --verbose",
51+
"fix:js": "pnpm lint:js --fix",
52+
"fix:md": "pnpm lint:md --fix",
53+
"fix:pkg": "syncpack format ; syncpack fix-mismatches",
54+
"lint": "concurrently \"pnpm:lint:*\" --group --timings",
55+
"lint:deps": "depcheck",
56+
"lint:format": "pnpm fix:format --check",
57+
"lint:js": "DEBUG=\"eslint:cli-engine\" eslint . --ext .cjs,.js,.ts,.json,.yml --cache --cache-location \"./node_modules/.cache/eslint\"",
58+
"lint:md": "markdownlint . --config \"../../.markdownlint.json\" --dot --ignore \"./LICENSE.md\" --ignore-path \"../../.gitignore\"",
59+
"lint:pkg": "syncpack list-mismatches",
60+
"lint:types": "tsc --noEmit",
61+
"test:unit": "vitest run --dir \"./source\""
62+
},
63+
"dependencies": {
64+
"@terminal-nerds/snippets-runtime": "workspace:*",
65+
"@terminal-nerds/snippets-type": "workspace:*",
66+
"zod": "3.20.6"
67+
},
68+
"devDependencies": {
69+
"@terminal-nerds/snippets-test": "workspace:*"
70+
}
71+
}

packages/function/source/main.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/* MODULES */
2+
export * from "./schema/schema.js";

0 commit comments

Comments
 (0)