flatlock 1.0.1
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 +201 -0
- package/README.md +94 -0
- package/bin/flatlock-cmp.js +514 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/package.json +85 -0
- package/src/detect.js +153 -0
- package/src/index.js +144 -0
- package/src/parsers/index.js +8 -0
- package/src/parsers/npm.js +96 -0
- package/src/parsers/pnpm.js +81 -0
- package/src/parsers/yarn-berry.js +105 -0
- package/src/parsers/yarn-classic.js +105 -0
- package/src/result.js +35 -0
package/src/result.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @template T
|
|
3
|
+
* @typedef {Object} OkResult
|
|
4
|
+
* @property {true} ok
|
|
5
|
+
* @property {T} value
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @typedef {Object} ErrResult
|
|
10
|
+
* @property {false} ok
|
|
11
|
+
* @property {Error} error
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @template T
|
|
16
|
+
* @typedef {OkResult<T> | ErrResult} Result
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Create a successful Result
|
|
21
|
+
* @template T
|
|
22
|
+
* @param {T} value - The success value
|
|
23
|
+
* @returns {OkResult<T>}
|
|
24
|
+
*/
|
|
25
|
+
export const Ok = (value) => ({ ok: true, value });
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Create a failed Result
|
|
29
|
+
* @param {Error | string} error - The error
|
|
30
|
+
* @returns {ErrResult}
|
|
31
|
+
*/
|
|
32
|
+
export const Err = (error) => ({
|
|
33
|
+
ok: false,
|
|
34
|
+
error: error instanceof Error ? error : new Error(error)
|
|
35
|
+
});
|