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

Commit 5aa3256

Browse files
authored
feat(array): ✨ Add snippets related to array (#65)
1 parent 3e6b248 commit 5aa3256

40 files changed

+1319
-2
lines changed

.changeset/cuddly-cats-rush.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
"@terminal-nerds/snippets-array": minor
3+
---
4+
5+
✨ Added a new, initial modules:
6+
7+
- `compare`
8+
- `difference`
9+
- `filter`
10+
- `intersection`
11+
- `random`
12+
- `schema`
13+
- `shuffle`
14+
- `union`
15+
- `unique`

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ Reusable pieces of code, which can be **reused** across the projects.
100100
| ------------------------------- | ------------------------------------------------ |
101101
| [![snippets badge]][snippets] | [![snippets version badge]][snippets npm page] |
102102
| <!-- PACKAGES --> | <!-- PACKAGES --> |
103+
| [![array badge]][array] | [![array version badge]][array npm page] |
103104
| [![number badge]][number] | [![number version badge]][number npm page] |
104105
| [![config badge]][config] | [![config version badge]][config npm page] |
105106
| [![extension badge]][extension] | [![extension version badge]][extension npm page] |
@@ -117,6 +118,11 @@ Reusable pieces of code, which can be **reused** across the projects.
117118

118119
<!-- prettier-ignore-start -->
119120
<!-- PACKAGES LINKS -->
121+
[array]: ./packages/array/README.md
122+
[array badge]: https://img.shields.io/static/v1?label=%40terminal-nerds&message=snippets-array&style=flat-square&color=informational
123+
[array version badge]: https://img.shields.io/npm/v/@terminal-nerds/snippets-array/latest?style=flat-square&logo=npm
124+
[array npm page]: https://www.npmjs.com/package/@terminal-nerds/snippets-array
125+
120126
[number]: ./packages/number/README.md
121127
[number badge]: https://img.shields.io/static/v1?label=%40terminal-nerds&message=snippets-number&style=flat-square&color=informational
122128
[number version badge]: https://img.shields.io/npm/v/@terminal-nerds/snippets-number/latest?style=flat-square&logo=npm

packages/array/.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/array/CHANGELOG.md

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

packages/array/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/array/README.md

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

packages/array/package.json

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
{
2+
"$schema": "https://json.schemastore.org/package",
3+
"type": "module",
4+
"name": "@terminal-nerds/snippets-array",
5+
"version": "0.0.0",
6+
"description": "@terminal-nerds reusable snippets for arrays.",
7+
"keywords": [
8+
"snippets",
9+
"typescript",
10+
"array"
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/array"
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+
"require": "./dist/main.cjs"
33+
},
34+
"./*": {
35+
"types": "./dist/*/*.d.ts",
36+
"import": "./dist/*/*.js",
37+
"require": "./dist/*/*.cjs"
38+
},
39+
"./schema/*": {
40+
"types": "./dist/schema/*/*.d.ts",
41+
"import": "./dist/schema/*/*.js",
42+
"require": "./dist/schema/*/*.cjs"
43+
}
44+
},
45+
"files": [
46+
"dist/"
47+
],
48+
"scripts": {
49+
"build": "tsup",
50+
"clean": "concurrently \"pnpm:clean:*\" --group --timings",
51+
"clean:build": "del \"./dist\"",
52+
"clean:cache": "del \"./node_modules/.cache\"",
53+
"clean:test": "del \"./coverage\"",
54+
"dev:test": "vitest watch --ui",
55+
"dev:pkg": "tsup --watch",
56+
"fix": "concurrently \"pnpm:fix:*\" --group --timings",
57+
"fix:format": "pretty-quick --branch main --pattern \"packages/array/**/*\" --verbose",
58+
"fix:js": "pnpm lint:js --fix",
59+
"fix:md": "pnpm lint:md --fix",
60+
"fix:pkg": "syncpack format ; syncpack fix-mismatches",
61+
"lint": "concurrently \"pnpm:lint:*\" --group --timings",
62+
"lint:deps": "depcheck",
63+
"lint:format": "pnpm fix:format --check",
64+
"lint:js": "DEBUG=\"eslint:cli-engine\" eslint . --ext .cjs,.js,.ts,.json,.yml --cache --cache-location \"./node_modules/.cache/eslint\"",
65+
"lint:md": "markdownlint . --config \"../../.markdownlint.json\" --dot --ignore \"./LICENSE.md\" --ignore-path \"../../.gitignore\"",
66+
"lint:pkg": "syncpack list-mismatches",
67+
"lint:types": "tsc --noEmit",
68+
"test:unit": "vitest run --dir \"./source\""
69+
},
70+
"peerDependencies": {
71+
"typescript": "4.9.5"
72+
},
73+
"devDependencies": {
74+
"@terminal-nerds/snippets-test": "workspace:*"
75+
},
76+
"peerDependenciesMeta": {
77+
"typescript": {
78+
"optional": true
79+
}
80+
},
81+
"dependencies": {
82+
"@terminal-nerds/snippets-number": "workspace:*",
83+
"@terminal-nerds/snippets-type": "workspace:*",
84+
"array-differ": "4.0.0",
85+
"array-union": "3.0.1",
86+
"fast-deep-equal": "3.1.3",
87+
"zod": "3.21.4"
88+
}
89+
}

0 commit comments

Comments
 (0)