raindrops-on-roses 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +194 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +4 -2
package/README.md
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# raindrops-on-roses
|
|
2
|
+
|
|
3
|
+
[](https://npmx.dev/package/raindrops-on-roses)
|
|
4
|
+
[](https://npmx.dev/package/raindrops-on-roses)
|
|
5
|
+
[](https://npmx.dev/package/raindrops-on-roses)
|
|
6
|
+
[](https://npmx.dev/package/raindrops-on-roses)
|
|
7
|
+
|
|
8
|
+
> A collection of delicately crafted TS functions from passionate OSS maintainers, 100% tested and made with love.
|
|
9
|
+
|
|
10
|
+
<img width="1280" height="640" alt="image" src="https://github.com/user-attachments/assets/cba604e3-b767-41b7-bb3b-21b07fc9d0b3" />
|
|
11
|
+
|
|
12
|
+
_When the dog bites\
|
|
13
|
+
When the bee stings\
|
|
14
|
+
When I'm feeling sad\
|
|
15
|
+
I simply remember my favourite things\
|
|
16
|
+
And then I don't feel so bad_
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
npm install raindrops-on-roses
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { clamp } from "raindrops-on-roses";
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Contribute
|
|
31
|
+
|
|
32
|
+
`raindrops-on-roses` is an open-source library, and welcomes contributions from humans. If like us you love crafting beautiful and useful utilities, you can open a PR!
|
|
33
|
+
|
|
34
|
+
### Rules regarding LLM usage
|
|
35
|
+
|
|
36
|
+
- LLM usage is permitted for coding, provided you can explain what the code actually does.
|
|
37
|
+
- LLM usage in PR and issue descriptions is **not permitted**. If so, they will be closed swiftly. We believe open-source must put community first, and communicating with your own voice is critical. You can communicate in your own language, you can make mistakes and typos in your messages.
|
|
38
|
+
|
|
39
|
+
### Adding a new function
|
|
40
|
+
|
|
41
|
+
- Clone the repository and install dependencies:
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
npm install
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
- Use the generator to create a new function:
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
npm run add:function -- <functionName>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
- The generator will prompt you to:
|
|
54
|
+
- choose whether the function is `pure` or `composed`
|
|
55
|
+
- choose an existing category, such as `numbers`, or create a new one
|
|
56
|
+
|
|
57
|
+
- Each function is created as its own npm workspace package. The generator creates:
|
|
58
|
+
- `src/index.ts` for the implementation
|
|
59
|
+
- `test/index.test.ts` for tests
|
|
60
|
+
- `package.json` for the individual npm package
|
|
61
|
+
- `tsconfig.json`
|
|
62
|
+
- `vite.config.ts`
|
|
63
|
+
- the corresponding dependency and export in the `raindrops-on-roses` umbrella package
|
|
64
|
+
|
|
65
|
+
- New utility packages start at version `0.0.0`.
|
|
66
|
+
|
|
67
|
+
- After generating a function, install again so npm registers the new workspace:
|
|
68
|
+
|
|
69
|
+
```sh
|
|
70
|
+
npm install
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
- The generated tests are intentionally incomplete and should initially fail.
|
|
74
|
+
|
|
75
|
+
- Implement and document the function, then replace the placeholder test with meaningful test cases.
|
|
76
|
+
|
|
77
|
+
- Every function must:
|
|
78
|
+
- be fully typed
|
|
79
|
+
- have JSDoc documentation
|
|
80
|
+
- have 100% test coverage
|
|
81
|
+
|
|
82
|
+
- Run the full test suite:
|
|
83
|
+
|
|
84
|
+
```sh
|
|
85
|
+
npm run test
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
- Check coverage:
|
|
89
|
+
|
|
90
|
+
```sh
|
|
91
|
+
npm run coverage
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
- Verify that every package builds successfully:
|
|
95
|
+
|
|
96
|
+
```sh
|
|
97
|
+
npm run build
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
You should not need to manually add the function to the umbrella `package.json`, `index.ts`, or Vite configuration. The generator handles this automatically.
|
|
101
|
+
|
|
102
|
+
Do not attempt to publish packages created as part of a contribution. Publishing and versioning are handled by the maintainers as part of the release process.
|
|
103
|
+
|
|
104
|
+
### File system
|
|
105
|
+
|
|
106
|
+
There are two types of functions:
|
|
107
|
+
|
|
108
|
+
- **pure**: an independent unit with no side effects and no dependency on other `raindrops-on-roses` utilities
|
|
109
|
+
- **composed**: a function built by composing existing utilities
|
|
110
|
+
|
|
111
|
+
Every utility is also an independent npm workspace package.
|
|
112
|
+
|
|
113
|
+
For example, the `clamp` utility is stored as:
|
|
114
|
+
|
|
115
|
+
```text
|
|
116
|
+
packages/
|
|
117
|
+
├── pure/
|
|
118
|
+
│ └── numbers/
|
|
119
|
+
│ └── clamp/
|
|
120
|
+
│ ├── src/
|
|
121
|
+
│ │ └── index.ts
|
|
122
|
+
│ ├── test/
|
|
123
|
+
│ │ └── index.test.ts
|
|
124
|
+
│ ├── package.json
|
|
125
|
+
│ ├── tsconfig.json
|
|
126
|
+
│ └── vite.config.ts
|
|
127
|
+
│
|
|
128
|
+
└── raindrops-on-roses/
|
|
129
|
+
├── src/
|
|
130
|
+
│ └── index.ts
|
|
131
|
+
├── package.json
|
|
132
|
+
├── tsconfig.json
|
|
133
|
+
└── vite.config.ts
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
The directory hierarchy describes the kind of utility:
|
|
137
|
+
|
|
138
|
+
```text
|
|
139
|
+
packages/<type>/<category>/<utility>/
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
For example:
|
|
143
|
+
|
|
144
|
+
```text
|
|
145
|
+
packages/pure/numbers/clamp/
|
|
146
|
+
packages/pure/numbers/numbers-from-seed/
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
The utility directory name uses kebab-case, while the exported JavaScript function keeps its normal camelCase name:
|
|
150
|
+
|
|
151
|
+
```text
|
|
152
|
+
numbersFromSeed
|
|
153
|
+
↓
|
|
154
|
+
packages/pure/numbers/numbers-from-seed/
|
|
155
|
+
↓
|
|
156
|
+
@aleclloydprobert/numbers-from-seed
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Each utility package can be installed independently:
|
|
160
|
+
|
|
161
|
+
```sh
|
|
162
|
+
npm install @aleclloydprobert/clamp
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
and imported directly:
|
|
166
|
+
|
|
167
|
+
```ts
|
|
168
|
+
import { clamp } from "@aleclloydprobert/clamp";
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
The same utility is also re-exported by the umbrella package:
|
|
172
|
+
|
|
173
|
+
```ts
|
|
174
|
+
import { clamp } from "raindrops-on-roses";
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
The umbrella package depends on the individual utility packages and provides the complete library API while remaining tree-shakeable.
|
|
178
|
+
|
|
179
|
+
When using:
|
|
180
|
+
|
|
181
|
+
```sh
|
|
182
|
+
npm run add:function -- <functionName>
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
you will be prompted to select:
|
|
186
|
+
|
|
187
|
+
1. `pure` or `composed`
|
|
188
|
+
2. an existing category or a new category
|
|
189
|
+
|
|
190
|
+
The generator then creates the complete workspace package in the appropriate location.
|
|
191
|
+
|
|
192
|
+
### Show your love
|
|
193
|
+
|
|
194
|
+
- In the JsDoc above your function, feel free to add a quote you like. It should ideally be related to the function.
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "raindrops-on-roses",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"files": [
|
|
@@ -14,10 +14,12 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@aleclloydprobert/clamp": "0.0.1",
|
|
17
|
+
"@aleclloydprobert/nice-number": "0.0.1",
|
|
17
18
|
"@aleclloydprobert/numbers-from-seed": "0.0.1"
|
|
18
19
|
},
|
|
19
20
|
"scripts": {
|
|
20
|
-
"build": "tsc -p tsconfig.json"
|
|
21
|
+
"build": "tsc -p tsconfig.json",
|
|
22
|
+
"prepack": "node ../../scripts/copy-readme.mjs"
|
|
21
23
|
},
|
|
22
24
|
"license": "MIT",
|
|
23
25
|
"repository": {
|