@opndev/util 0.0.8 → 0.0.10

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,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020-2024 Wesley Schwengle
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,9 @@
1
+ <!--
2
+ SPDX-FileCopyrightText: 2020-2024 Wesley Schwengle <wesley@opndev.io>
3
+
4
+ SPDX-License-Identifier: MIT
5
+ -->
6
+
1
7
  # Welcome to @opndev/util
2
8
 
3
9
  This is a utility function package that tries to solve issues by keeping things
package/lib/any.mjs CHANGED
@@ -1,3 +1,7 @@
1
+ // SPDX-FileCopyrightText: 2021-2024 Wesley Schwengle <wesley@opndev.io>
2
+ //
3
+ // SPDX-License-Identifier: MIT
4
+
1
5
  /**
2
6
  * Check if a value is preset in the given array, can be done via a function or
3
7
  * a primitive. Objects tend to be harder. Use lodash instead.
@@ -0,0 +1,19 @@
1
+ // SPDX-FileCopyrightText: 2026 Wesley Schwengle <wesley@opndev.io>
2
+ //
3
+ // SPDX-License-Identifier: MIT
4
+
5
+ /**
6
+ * Return an array if something is a scalar. This array-i-fies everything to an
7
+ * array. Perl ref $a ne 'ARRAY' ? [ $a ] : $a
8
+ *
9
+ * @function uniq
10
+ * @param {Anything} needle Anything
11
+ * @returns {Array} An array
12
+ */
13
+
14
+ export default function asArray(v) {
15
+ if (v == null) return [];
16
+ return Array.isArray(v) ? v : [v];
17
+ }
18
+
19
+ export { asArray }
package/lib/defined.mjs CHANGED
@@ -1,3 +1,7 @@
1
+ // SPDX-FileCopyrightText: 2021-2024 Wesley Schwengle <wesley@opndev.io>
2
+ //
3
+ // SPDX-License-Identifier: MIT
4
+
1
5
  /**
2
6
  * Check if a variable is defined
3
7
  * @function defined
package/lib/index.mjs CHANGED
@@ -1,3 +1,9 @@
1
+ // SPDX-FileCopyrightText: 2021-2024, 2026 Wesley Schwengle <wesley@opndev.io>
2
+ //
3
+ // SPDX-License-Identifier: MIT
4
+
5
+ const VERSION = "0.0.10";
6
+
1
7
  /**
2
8
  *
3
9
  * @module module:@opndev/utils
@@ -7,6 +13,10 @@
7
13
  * @exports defined
8
14
  * @exports pow_of_two
9
15
  * @exports is_pow_of_two
16
+ * @exports uniq
17
+ * @exports ucFirst
18
+ * @exports lcFirst
19
+ * @exports range
10
20
  *
11
21
  * Export all the useful functions. Unfortunatly, without webpack's
12
22
  * require.context we cannot automaticly load everything. So we just keep
@@ -20,3 +30,5 @@ export { is_pow_of_two } from './ispowtwo.mjs'
20
30
  export { range } from './range.mjs'
21
31
  export { ucFirst } from './ucFirst.mjs'
22
32
  export { lcFirst } from './lcFirst.mjs'
33
+ export { uniq } from './uniq.mjs'
34
+ export { asArray } from './asArray.mjs'
package/lib/ispowtwo.mjs CHANGED
@@ -1,3 +1,7 @@
1
+ // SPDX-FileCopyrightText: 2023, 2024 Wesley Schwengle <wesley@opndev.io>
2
+ //
3
+ // SPDX-License-Identifier: MIT
4
+
1
5
  /**
2
6
  * Check if something is the power of two
3
7
  * @function is_pow_of_two
package/lib/lcFirst.mjs CHANGED
@@ -1,3 +1,7 @@
1
+ // SPDX-FileCopyrightText: 2024 Wesley Schwengle <wesley@opndev.io>
2
+ //
3
+ // SPDX-License-Identifier: MIT
4
+
1
5
  /**
2
6
  * Check if a value is preset in the given array, can be done via a function or
3
7
  * a primitive. Objects tend to be harder. Use lodash instead.
package/lib/none.mjs CHANGED
@@ -1,3 +1,7 @@
1
+ // SPDX-FileCopyrightText: 2023, 2024 Wesley Schwengle <wesley@opndev.io>
2
+ //
3
+ // SPDX-License-Identifier: MIT
4
+
1
5
  /**
2
6
  * Check if a value is not preset in the given array, can be done via a
3
7
  * function or a primitive.
package/lib/powtwo.mjs CHANGED
@@ -1,3 +1,7 @@
1
+ // SPDX-FileCopyrightText: 2023, 2024 Wesley Schwengle <wesley@opndev.io>
2
+ //
3
+ // SPDX-License-Identifier: MIT
4
+
1
5
  /**
2
6
  * Returns the power of two
3
7
  * @function pow_of_two
package/lib/range.mjs CHANGED
@@ -1,3 +1,7 @@
1
+ // SPDX-FileCopyrightText: 2023, 2024 Wesley Schwengle <wesley@opndev.io>
2
+ //
3
+ // SPDX-License-Identifier: MIT
4
+
1
5
  /**
2
6
  * Return a range
3
7
  * @function range
package/lib/ucFirst.mjs CHANGED
@@ -1,3 +1,7 @@
1
+ // SPDX-FileCopyrightText: 2024 Wesley Schwengle <wesley@opndev.io>
2
+ //
3
+ // SPDX-License-Identifier: MIT
4
+
1
5
  /**
2
6
  * Check if a value is preset in the given array, can be done via a function or
3
7
  * a primitive. Objects tend to be harder. Use lodash instead.
package/lib/uniq.mjs ADDED
@@ -0,0 +1,16 @@
1
+ // SPDX-FileCopyrightText: 2026 Wesley Schwengle <wesley@opndev.io>
2
+ //
3
+ // SPDX-License-Identifier: MIT
4
+
5
+ /**
6
+ * Return an array with uniq values
7
+ *
8
+ * @function uniq
9
+ * @param {Array} needle Anything
10
+ * @returns {Array} An array with unique values
11
+ */
12
+ export default function uniq(arr) {
13
+ return [...new Set(arr.filter((x) => x != null && x !== ""))];
14
+ }
15
+
16
+ export { uniq }
package/package.json CHANGED
@@ -1,35 +1,43 @@
1
1
  {
2
- "name": "@opndev/util",
3
- "version": "0.0.8",
4
- "description": "Utility functions for OPN Development",
5
- "main": "lib/index.mjs",
6
- "type": "module",
7
- "mode": "auto",
8
- "sideEffects": false,
9
- "homepage": "https://opndev.gitlab.io/javascript/opndev-js-util/",
10
- "repository": {
11
- "url": "git+https://gitlab.com/opndev/javascript/opndev-js-util.git"
12
- },
13
- "bugs": {
14
- "url": "https://gitlab.com/opndev/javascript/opndev-js-util/issues"
15
- },
16
- "scripts": {
17
- "test": "tap",
18
- "jsdoc" : "jsdoc -c jsdoc.json"
19
- },
20
2
  "author": {
21
- "name": "Wesley Schwengle",
22
3
  "email": "wesley@opndev.io",
4
+ "name": "Wesley Schwengle",
23
5
  "url": "https://opndev.io"
24
6
  },
25
- "license": "MIT",
7
+ "bugs": {
8
+ "url": "https://gitlab.com/opndev/javascript/opndev-js-util/-/issues"
9
+ },
10
+ "description": "Utility functions for OPN Development",
26
11
  "devDependencies": {
27
- "jsdoc" : "latest",
12
+ "jsdoc": "latest",
28
13
  "tap": "latest"
29
14
  },
30
- "files": [
31
- "lib/*.mjs",
32
- "README.md",
33
- "Changes"
34
- ]
15
+ "exports": {
16
+ ".": "./lib/index.mjs",
17
+ "./any": "./lib/any.mjs",
18
+ "./defined": "./lib/defined.mjs",
19
+ "./is_pow_of_two": "./lib/is_pow_of_two.mjs",
20
+ "./lcFirst": "./lib/lcFirst.mjs",
21
+ "./none": "./lib/none.mjs",
22
+ "./pow_of_two": "./lib/pow_of_two.mjs",
23
+ "./range": "./lib/range.mjs",
24
+ "./ucFirst": "./lib/ucFirst.mjs"
25
+ },
26
+ "homepage": "https://opndev.gitlab.io/javascript/opndev-js-util/",
27
+ "keywords": [
28
+ "utility"
29
+ ],
30
+ "license": "MIT",
31
+ "name": "@opndev/util",
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "git+https://gitlab.com/opndev/javascript/opndev-js-util.git"
35
+ },
36
+ "scripts": {
37
+ "jsdoc": "jsdoc -c jsdoc.json",
38
+ "test": "tap"
39
+ },
40
+ "sideEffects": false,
41
+ "type": "module",
42
+ "version": "0.0.10"
35
43
  }
package/Changes DELETED
@@ -1,41 +0,0 @@
1
- Revision history for @opndev/util
2
-
3
- 0.08 2024-06-04 11:55:03-0400
4
-
5
- * Add ucFirst, lcFirst functions. Why doesn't JS have these in core?
6
-
7
- 0.0.7 2024-01-19 14:19:56-0400
8
-
9
- * Add additional information when throwing an error in pow functions
10
- * Bump requirements for node-tap
11
-
12
- 0.0.6 2023-09-03 17:20:58-0400
13
-
14
- * Maintainer release:
15
- * Make use of gitlab pages for documenation
16
- * Add none() function
17
- * Add range() function
18
- * Bugfix: Allow string values in pow_* functions
19
-
20
- 0.0.5 2023-08-27 15:33:21-0400
21
-
22
- * Include .mjs files in package
23
-
24
- 0.0.4 2023-08-27 15:13:21-0400
25
-
26
- * Add two mathematical functions:
27
- * is_pow_of_two
28
- * pow_of_two
29
-
30
- 0.0.3 2021-11-12 17:15:02-0400
31
-
32
- * maintainer release for ESM
33
-
34
- 0.0.2 2020-05-15 16:19:23Z
35
-
36
- * Allow any() to check for integers as well
37
- * Update README.md
38
-
39
- 0.0.1 2020-05-13 02:42:33Z
40
-
41
- * First release