safe-wrapper 1.0.6

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Mohammed Muzammil Anwar
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,107 @@
1
+ ## safe-wrapper
2
+
3
+ safe-wrapper is a lightweight utility for javascript that simplifies error handling for both synchronous and asynchronous functions. inspired by the [safe assignment operator proposal](https://github.com/arthurfiorette/proposal-safe-assignment-operator), this utility allows for graceful error management by returning a tuple of the result and error, making it easy to handle various error types.
4
+
5
+ #### Installation
6
+
7
+ ```
8
+ npm install safe-wrapper
9
+ ```
10
+
11
+ #### Usage
12
+
13
+ import `safe` from `safe-wrapper` to use it with any function. it takes the result of a function as its first argument and an optional array of `error types` to catch as the second argument. the function returns an array `[error, result]`, where `error` is an instance of the specified error type or `null` if successful, and `result` is the result of the function when there is no error.
14
+
15
+ #### synchronous example
16
+
17
+ in this example, we handle a synchronous function that may return an error.
18
+
19
+ ```javascript
20
+ import { safe } from 'safe-wrapper';
21
+
22
+ const sync = () => {
23
+ return new Error('sync error occurred');
24
+ }
25
+
26
+ const [error, result] = safe(sync());
27
+
28
+ if (error) {
29
+ return handle(error);
30
+ }
31
+
32
+ return handle(result);
33
+ ```
34
+
35
+ #### synchronous example with error type check
36
+
37
+ we can specify error types to catch specific errors. if an unknown error type occurs, it will be thrown instead.
38
+
39
+ ```javascript
40
+ import { safe } from 'safe-wrapper';
41
+
42
+ const sync = () => {
43
+ return new TypeError('sync type error occurred');
44
+ }
45
+
46
+ const [error, result] = safe(sync(), [TypeError]);
47
+
48
+ if (error) {
49
+ return handle(error);
50
+ }
51
+
52
+ return handle(result);
53
+ ```
54
+
55
+ #### asynchronous example
56
+
57
+ in this example, we handle a synchronous function that may throw an error.
58
+
59
+ ```javascript
60
+ import { safe } from 'safe-wrapper';
61
+
62
+ const async = () => {
63
+ throw new Error('async error occurred');
64
+ }
65
+
66
+ const [error, result] = await safe(async());
67
+
68
+ if (error) {
69
+ return handle(error);
70
+ }
71
+
72
+ return handle(result);
73
+ ```
74
+
75
+ #### asynchronous example with error type check
76
+
77
+ we can specify error types with asynchronous functions as well.
78
+
79
+ ```javascript
80
+ import { safe } from 'safe-wrapper';
81
+
82
+ const async = () => {
83
+ throw new TypeError('async type error occurred');
84
+ }
85
+
86
+ const [error, result] = await safe(async(), [TypeError]);
87
+
88
+ if (error) {
89
+ return handle(error);
90
+ }
91
+
92
+ return handle(result);
93
+ ```
94
+
95
+ #### Important Notes
96
+ - async operations: should throw errors when they fail.
97
+ - sync operations: should return errors instead of throwing them.
98
+
99
+ #### API
100
+
101
+ ```safe(response, types)```
102
+ - parameters
103
+ - response (any): result of the function call, either synchronous or asynchronous.
104
+ - types (array, optional): an array of error types to catch specifically. if an error does not match any of these types, it will be thrown.
105
+ - returns `[error, result]`
106
+ - error (error | null): the error caught from the function, if any.
107
+ - result (any): the result of the function, if no error occurs.
package/lib/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";var c=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var o=Object.prototype.hasOwnProperty;var r=(n,t)=>{for(var u in t)c(n,u,{get:t[u],enumerable:!0})},g=(n,t,u,f)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of h(t))!o.call(n,l)&&l!==u&&c(n,l,{get:()=>t[l],enumerable:!(f=a(t,l))||f.enumerable});return n};var m=n=>g(c({},"__esModule",{value:!0}),n);var w={};r(w,{safe:()=>e});module.exports=m(w);var i=(n,t=[])=>{if(!t.length)return[n,null];if(t.some(u=>n instanceof u))return[n,null];throw n},e=(n,t=[])=>n instanceof Promise?n.then(u=>[null,u]).catch(u=>i(u,t)):n instanceof Error?i(n,t):[null,n];
package/lib/index.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * safely executes the result of a function or a promise and handles any errors that occur.
3
+ *
4
+ * @param {any} response - the result of a synchronous or asynchronous function, or a promise to execute.
5
+ * @param {Array<ErrorConstructor>} [types=[]] - an optional array of error classes to check against.
6
+ * @returns {Promise<[null, any]|[Error, null]>|[null, any]|[Error, null]} - returns an array where the first element is null if successful, or an error if it fails. if the input is a promise, it resolves to that array; otherwise, it returns the array directly.
7
+ */
8
+ export function safe(response: any, types?: ErrorConstructor[] | undefined): Promise<[null, any] | [Error, null]> | [null, any] | [Error, null];
package/lib/index.mjs ADDED
@@ -0,0 +1 @@
1
+ var l=(n,t=[])=>{if(!t.length)return[n,null];if(t.some(u=>n instanceof u))return[n,null];throw n},c=(n,t=[])=>n instanceof Promise?n.then(u=>[null,u]).catch(u=>l(u,t)):n instanceof Error?l(n,t):[null,n];export{c as safe};
@@ -0,0 +1,453 @@
1
+ {
2
+ "name": "safe-wrapper",
3
+ "version": "1.0.0",
4
+ "lockfileVersion": 3,
5
+ "requires": true,
6
+ "packages": {
7
+ "": {
8
+ "name": "safe-wrapper",
9
+ "version": "1.0.0",
10
+ "license": "MIT",
11
+ "devDependencies": {
12
+ "esbuild": "^0.24.0",
13
+ "typescript": "^5.6.3"
14
+ }
15
+ },
16
+ "node_modules/@esbuild/aix-ppc64": {
17
+ "version": "0.24.0",
18
+ "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.24.0.tgz",
19
+ "integrity": "sha512-WtKdFM7ls47zkKHFVzMz8opM7LkcsIp9amDUBIAWirg70RM71WRSjdILPsY5Uv1D42ZpUfaPILDlfactHgsRkw==",
20
+ "cpu": [
21
+ "ppc64"
22
+ ],
23
+ "dev": true,
24
+ "optional": true,
25
+ "os": [
26
+ "aix"
27
+ ],
28
+ "engines": {
29
+ "node": ">=18"
30
+ }
31
+ },
32
+ "node_modules/@esbuild/android-arm": {
33
+ "version": "0.24.0",
34
+ "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.24.0.tgz",
35
+ "integrity": "sha512-arAtTPo76fJ/ICkXWetLCc9EwEHKaeya4vMrReVlEIUCAUncH7M4bhMQ+M9Vf+FFOZJdTNMXNBrWwW+OXWpSew==",
36
+ "cpu": [
37
+ "arm"
38
+ ],
39
+ "dev": true,
40
+ "optional": true,
41
+ "os": [
42
+ "android"
43
+ ],
44
+ "engines": {
45
+ "node": ">=18"
46
+ }
47
+ },
48
+ "node_modules/@esbuild/android-arm64": {
49
+ "version": "0.24.0",
50
+ "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.24.0.tgz",
51
+ "integrity": "sha512-Vsm497xFM7tTIPYK9bNTYJyF/lsP590Qc1WxJdlB6ljCbdZKU9SY8i7+Iin4kyhV/KV5J2rOKsBQbB77Ab7L/w==",
52
+ "cpu": [
53
+ "arm64"
54
+ ],
55
+ "dev": true,
56
+ "optional": true,
57
+ "os": [
58
+ "android"
59
+ ],
60
+ "engines": {
61
+ "node": ">=18"
62
+ }
63
+ },
64
+ "node_modules/@esbuild/android-x64": {
65
+ "version": "0.24.0",
66
+ "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.24.0.tgz",
67
+ "integrity": "sha512-t8GrvnFkiIY7pa7mMgJd7p8p8qqYIz1NYiAoKc75Zyv73L3DZW++oYMSHPRarcotTKuSs6m3hTOa5CKHaS02TQ==",
68
+ "cpu": [
69
+ "x64"
70
+ ],
71
+ "dev": true,
72
+ "optional": true,
73
+ "os": [
74
+ "android"
75
+ ],
76
+ "engines": {
77
+ "node": ">=18"
78
+ }
79
+ },
80
+ "node_modules/@esbuild/darwin-arm64": {
81
+ "version": "0.24.0",
82
+ "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.24.0.tgz",
83
+ "integrity": "sha512-CKyDpRbK1hXwv79soeTJNHb5EiG6ct3efd/FTPdzOWdbZZfGhpbcqIpiD0+vwmpu0wTIL97ZRPZu8vUt46nBSw==",
84
+ "cpu": [
85
+ "arm64"
86
+ ],
87
+ "dev": true,
88
+ "optional": true,
89
+ "os": [
90
+ "darwin"
91
+ ],
92
+ "engines": {
93
+ "node": ">=18"
94
+ }
95
+ },
96
+ "node_modules/@esbuild/darwin-x64": {
97
+ "version": "0.24.0",
98
+ "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.24.0.tgz",
99
+ "integrity": "sha512-rgtz6flkVkh58od4PwTRqxbKH9cOjaXCMZgWD905JOzjFKW+7EiUObfd/Kav+A6Gyud6WZk9w+xu6QLytdi2OA==",
100
+ "cpu": [
101
+ "x64"
102
+ ],
103
+ "dev": true,
104
+ "optional": true,
105
+ "os": [
106
+ "darwin"
107
+ ],
108
+ "engines": {
109
+ "node": ">=18"
110
+ }
111
+ },
112
+ "node_modules/@esbuild/freebsd-arm64": {
113
+ "version": "0.24.0",
114
+ "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.24.0.tgz",
115
+ "integrity": "sha512-6Mtdq5nHggwfDNLAHkPlyLBpE5L6hwsuXZX8XNmHno9JuL2+bg2BX5tRkwjyfn6sKbxZTq68suOjgWqCicvPXA==",
116
+ "cpu": [
117
+ "arm64"
118
+ ],
119
+ "dev": true,
120
+ "optional": true,
121
+ "os": [
122
+ "freebsd"
123
+ ],
124
+ "engines": {
125
+ "node": ">=18"
126
+ }
127
+ },
128
+ "node_modules/@esbuild/freebsd-x64": {
129
+ "version": "0.24.0",
130
+ "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.24.0.tgz",
131
+ "integrity": "sha512-D3H+xh3/zphoX8ck4S2RxKR6gHlHDXXzOf6f/9dbFt/NRBDIE33+cVa49Kil4WUjxMGW0ZIYBYtaGCa2+OsQwQ==",
132
+ "cpu": [
133
+ "x64"
134
+ ],
135
+ "dev": true,
136
+ "optional": true,
137
+ "os": [
138
+ "freebsd"
139
+ ],
140
+ "engines": {
141
+ "node": ">=18"
142
+ }
143
+ },
144
+ "node_modules/@esbuild/linux-arm": {
145
+ "version": "0.24.0",
146
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.24.0.tgz",
147
+ "integrity": "sha512-gJKIi2IjRo5G6Glxb8d3DzYXlxdEj2NlkixPsqePSZMhLudqPhtZ4BUrpIuTjJYXxvF9njql+vRjB2oaC9XpBw==",
148
+ "cpu": [
149
+ "arm"
150
+ ],
151
+ "dev": true,
152
+ "optional": true,
153
+ "os": [
154
+ "linux"
155
+ ],
156
+ "engines": {
157
+ "node": ">=18"
158
+ }
159
+ },
160
+ "node_modules/@esbuild/linux-arm64": {
161
+ "version": "0.24.0",
162
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.24.0.tgz",
163
+ "integrity": "sha512-TDijPXTOeE3eaMkRYpcy3LarIg13dS9wWHRdwYRnzlwlA370rNdZqbcp0WTyyV/k2zSxfko52+C7jU5F9Tfj1g==",
164
+ "cpu": [
165
+ "arm64"
166
+ ],
167
+ "dev": true,
168
+ "optional": true,
169
+ "os": [
170
+ "linux"
171
+ ],
172
+ "engines": {
173
+ "node": ">=18"
174
+ }
175
+ },
176
+ "node_modules/@esbuild/linux-ia32": {
177
+ "version": "0.24.0",
178
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.24.0.tgz",
179
+ "integrity": "sha512-K40ip1LAcA0byL05TbCQ4yJ4swvnbzHscRmUilrmP9Am7//0UjPreh4lpYzvThT2Quw66MhjG//20mrufm40mA==",
180
+ "cpu": [
181
+ "ia32"
182
+ ],
183
+ "dev": true,
184
+ "optional": true,
185
+ "os": [
186
+ "linux"
187
+ ],
188
+ "engines": {
189
+ "node": ">=18"
190
+ }
191
+ },
192
+ "node_modules/@esbuild/linux-loong64": {
193
+ "version": "0.24.0",
194
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.24.0.tgz",
195
+ "integrity": "sha512-0mswrYP/9ai+CU0BzBfPMZ8RVm3RGAN/lmOMgW4aFUSOQBjA31UP8Mr6DDhWSuMwj7jaWOT0p0WoZ6jeHhrD7g==",
196
+ "cpu": [
197
+ "loong64"
198
+ ],
199
+ "dev": true,
200
+ "optional": true,
201
+ "os": [
202
+ "linux"
203
+ ],
204
+ "engines": {
205
+ "node": ">=18"
206
+ }
207
+ },
208
+ "node_modules/@esbuild/linux-mips64el": {
209
+ "version": "0.24.0",
210
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.24.0.tgz",
211
+ "integrity": "sha512-hIKvXm0/3w/5+RDtCJeXqMZGkI2s4oMUGj3/jM0QzhgIASWrGO5/RlzAzm5nNh/awHE0A19h/CvHQe6FaBNrRA==",
212
+ "cpu": [
213
+ "mips64el"
214
+ ],
215
+ "dev": true,
216
+ "optional": true,
217
+ "os": [
218
+ "linux"
219
+ ],
220
+ "engines": {
221
+ "node": ">=18"
222
+ }
223
+ },
224
+ "node_modules/@esbuild/linux-ppc64": {
225
+ "version": "0.24.0",
226
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.24.0.tgz",
227
+ "integrity": "sha512-HcZh5BNq0aC52UoocJxaKORfFODWXZxtBaaZNuN3PUX3MoDsChsZqopzi5UupRhPHSEHotoiptqikjN/B77mYQ==",
228
+ "cpu": [
229
+ "ppc64"
230
+ ],
231
+ "dev": true,
232
+ "optional": true,
233
+ "os": [
234
+ "linux"
235
+ ],
236
+ "engines": {
237
+ "node": ">=18"
238
+ }
239
+ },
240
+ "node_modules/@esbuild/linux-riscv64": {
241
+ "version": "0.24.0",
242
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.24.0.tgz",
243
+ "integrity": "sha512-bEh7dMn/h3QxeR2KTy1DUszQjUrIHPZKyO6aN1X4BCnhfYhuQqedHaa5MxSQA/06j3GpiIlFGSsy1c7Gf9padw==",
244
+ "cpu": [
245
+ "riscv64"
246
+ ],
247
+ "dev": true,
248
+ "optional": true,
249
+ "os": [
250
+ "linux"
251
+ ],
252
+ "engines": {
253
+ "node": ">=18"
254
+ }
255
+ },
256
+ "node_modules/@esbuild/linux-s390x": {
257
+ "version": "0.24.0",
258
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.24.0.tgz",
259
+ "integrity": "sha512-ZcQ6+qRkw1UcZGPyrCiHHkmBaj9SiCD8Oqd556HldP+QlpUIe2Wgn3ehQGVoPOvZvtHm8HPx+bH20c9pvbkX3g==",
260
+ "cpu": [
261
+ "s390x"
262
+ ],
263
+ "dev": true,
264
+ "optional": true,
265
+ "os": [
266
+ "linux"
267
+ ],
268
+ "engines": {
269
+ "node": ">=18"
270
+ }
271
+ },
272
+ "node_modules/@esbuild/linux-x64": {
273
+ "version": "0.24.0",
274
+ "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.24.0.tgz",
275
+ "integrity": "sha512-vbutsFqQ+foy3wSSbmjBXXIJ6PL3scghJoM8zCL142cGaZKAdCZHyf+Bpu/MmX9zT9Q0zFBVKb36Ma5Fzfa8xA==",
276
+ "cpu": [
277
+ "x64"
278
+ ],
279
+ "dev": true,
280
+ "optional": true,
281
+ "os": [
282
+ "linux"
283
+ ],
284
+ "engines": {
285
+ "node": ">=18"
286
+ }
287
+ },
288
+ "node_modules/@esbuild/netbsd-x64": {
289
+ "version": "0.24.0",
290
+ "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.24.0.tgz",
291
+ "integrity": "sha512-hjQ0R/ulkO8fCYFsG0FZoH+pWgTTDreqpqY7UnQntnaKv95uP5iW3+dChxnx7C3trQQU40S+OgWhUVwCjVFLvg==",
292
+ "cpu": [
293
+ "x64"
294
+ ],
295
+ "dev": true,
296
+ "optional": true,
297
+ "os": [
298
+ "netbsd"
299
+ ],
300
+ "engines": {
301
+ "node": ">=18"
302
+ }
303
+ },
304
+ "node_modules/@esbuild/openbsd-arm64": {
305
+ "version": "0.24.0",
306
+ "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.24.0.tgz",
307
+ "integrity": "sha512-MD9uzzkPQbYehwcN583yx3Tu5M8EIoTD+tUgKF982WYL9Pf5rKy9ltgD0eUgs8pvKnmizxjXZyLt0z6DC3rRXg==",
308
+ "cpu": [
309
+ "arm64"
310
+ ],
311
+ "dev": true,
312
+ "optional": true,
313
+ "os": [
314
+ "openbsd"
315
+ ],
316
+ "engines": {
317
+ "node": ">=18"
318
+ }
319
+ },
320
+ "node_modules/@esbuild/openbsd-x64": {
321
+ "version": "0.24.0",
322
+ "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.24.0.tgz",
323
+ "integrity": "sha512-4ir0aY1NGUhIC1hdoCzr1+5b43mw99uNwVzhIq1OY3QcEwPDO3B7WNXBzaKY5Nsf1+N11i1eOfFcq+D/gOS15Q==",
324
+ "cpu": [
325
+ "x64"
326
+ ],
327
+ "dev": true,
328
+ "optional": true,
329
+ "os": [
330
+ "openbsd"
331
+ ],
332
+ "engines": {
333
+ "node": ">=18"
334
+ }
335
+ },
336
+ "node_modules/@esbuild/sunos-x64": {
337
+ "version": "0.24.0",
338
+ "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.24.0.tgz",
339
+ "integrity": "sha512-jVzdzsbM5xrotH+W5f1s+JtUy1UWgjU0Cf4wMvffTB8m6wP5/kx0KiaLHlbJO+dMgtxKV8RQ/JvtlFcdZ1zCPA==",
340
+ "cpu": [
341
+ "x64"
342
+ ],
343
+ "dev": true,
344
+ "optional": true,
345
+ "os": [
346
+ "sunos"
347
+ ],
348
+ "engines": {
349
+ "node": ">=18"
350
+ }
351
+ },
352
+ "node_modules/@esbuild/win32-arm64": {
353
+ "version": "0.24.0",
354
+ "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.24.0.tgz",
355
+ "integrity": "sha512-iKc8GAslzRpBytO2/aN3d2yb2z8XTVfNV0PjGlCxKo5SgWmNXx82I/Q3aG1tFfS+A2igVCY97TJ8tnYwpUWLCA==",
356
+ "cpu": [
357
+ "arm64"
358
+ ],
359
+ "dev": true,
360
+ "optional": true,
361
+ "os": [
362
+ "win32"
363
+ ],
364
+ "engines": {
365
+ "node": ">=18"
366
+ }
367
+ },
368
+ "node_modules/@esbuild/win32-ia32": {
369
+ "version": "0.24.0",
370
+ "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.24.0.tgz",
371
+ "integrity": "sha512-vQW36KZolfIudCcTnaTpmLQ24Ha1RjygBo39/aLkM2kmjkWmZGEJ5Gn9l5/7tzXA42QGIoWbICfg6KLLkIw6yw==",
372
+ "cpu": [
373
+ "ia32"
374
+ ],
375
+ "dev": true,
376
+ "optional": true,
377
+ "os": [
378
+ "win32"
379
+ ],
380
+ "engines": {
381
+ "node": ">=18"
382
+ }
383
+ },
384
+ "node_modules/@esbuild/win32-x64": {
385
+ "version": "0.24.0",
386
+ "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.24.0.tgz",
387
+ "integrity": "sha512-7IAFPrjSQIJrGsK6flwg7NFmwBoSTyF3rl7If0hNUFQU4ilTsEPL6GuMuU9BfIWVVGuRnuIidkSMC+c0Otu8IA==",
388
+ "cpu": [
389
+ "x64"
390
+ ],
391
+ "dev": true,
392
+ "optional": true,
393
+ "os": [
394
+ "win32"
395
+ ],
396
+ "engines": {
397
+ "node": ">=18"
398
+ }
399
+ },
400
+ "node_modules/esbuild": {
401
+ "version": "0.24.0",
402
+ "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.24.0.tgz",
403
+ "integrity": "sha512-FuLPevChGDshgSicjisSooU0cemp/sGXR841D5LHMB7mTVOmsEHcAxaH3irL53+8YDIeVNQEySh4DaYU/iuPqQ==",
404
+ "dev": true,
405
+ "hasInstallScript": true,
406
+ "bin": {
407
+ "esbuild": "bin/esbuild"
408
+ },
409
+ "engines": {
410
+ "node": ">=18"
411
+ },
412
+ "optionalDependencies": {
413
+ "@esbuild/aix-ppc64": "0.24.0",
414
+ "@esbuild/android-arm": "0.24.0",
415
+ "@esbuild/android-arm64": "0.24.0",
416
+ "@esbuild/android-x64": "0.24.0",
417
+ "@esbuild/darwin-arm64": "0.24.0",
418
+ "@esbuild/darwin-x64": "0.24.0",
419
+ "@esbuild/freebsd-arm64": "0.24.0",
420
+ "@esbuild/freebsd-x64": "0.24.0",
421
+ "@esbuild/linux-arm": "0.24.0",
422
+ "@esbuild/linux-arm64": "0.24.0",
423
+ "@esbuild/linux-ia32": "0.24.0",
424
+ "@esbuild/linux-loong64": "0.24.0",
425
+ "@esbuild/linux-mips64el": "0.24.0",
426
+ "@esbuild/linux-ppc64": "0.24.0",
427
+ "@esbuild/linux-riscv64": "0.24.0",
428
+ "@esbuild/linux-s390x": "0.24.0",
429
+ "@esbuild/linux-x64": "0.24.0",
430
+ "@esbuild/netbsd-x64": "0.24.0",
431
+ "@esbuild/openbsd-arm64": "0.24.0",
432
+ "@esbuild/openbsd-x64": "0.24.0",
433
+ "@esbuild/sunos-x64": "0.24.0",
434
+ "@esbuild/win32-arm64": "0.24.0",
435
+ "@esbuild/win32-ia32": "0.24.0",
436
+ "@esbuild/win32-x64": "0.24.0"
437
+ }
438
+ },
439
+ "node_modules/typescript": {
440
+ "version": "5.6.3",
441
+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.3.tgz",
442
+ "integrity": "sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==",
443
+ "dev": true,
444
+ "bin": {
445
+ "tsc": "bin/tsc",
446
+ "tsserver": "bin/tsserver"
447
+ },
448
+ "engines": {
449
+ "node": ">=14.17"
450
+ }
451
+ }
452
+ }
453
+ }
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "safe-wrapper",
3
+ "version": "1.0.6",
4
+ "description": "a js-util for safely wrapping synchronous and asynchronous functions to handle errors based on specified types.",
5
+ "type": "module",
6
+ "main": "lib/index.cjs",
7
+ "types": "lib/index.d.ts",
8
+ "module": "lib/index.mjs",
9
+ "scripts": {
10
+ "build": "rm -rf lib && node esbuild.config.js",
11
+ "ci": "npm install --clean-install && npm test && npm run build",
12
+ "start": "node src/index.js",
13
+ "test": "node --test",
14
+ "publish": "npm publish --access public"
15
+ },
16
+ "exports": {
17
+ ".": {
18
+ "import": "./lib/index.mjs",
19
+ "types": "./lib/index.d.ts",
20
+ "require": "./lib/index.cjs"
21
+ }
22
+ },
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/mcking-07/safe-wrapper.git"
26
+ },
27
+ "keywords": [
28
+ "error",
29
+ "wrapper",
30
+ "safe",
31
+ "async",
32
+ "sync"
33
+ ],
34
+ "author": "mcking-07",
35
+ "license": "MIT",
36
+ "bugs": {
37
+ "url": "https://github.com/mcking-07/safe-wrapper/issues"
38
+ },
39
+ "homepage": "https://github.com/mcking-07/safe-wrapper#readme",
40
+ "devDependencies": {
41
+ "esbuild": "^0.24.0",
42
+ "typescript": "^5.6.3"
43
+ }
44
+ }