cno-bedrock 0.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.
@@ -0,0 +1,48 @@
1
+ name: ci
2
+ 'on':
3
+ - push
4
+ - pull_request
5
+ jobs:
6
+ source:
7
+ strategy:
8
+ matrix:
9
+ os:
10
+ - ubuntu-latest
11
+ - macos-latest
12
+ - windows-latest
13
+ node:
14
+ - '18'
15
+ - '20'
16
+ - latest
17
+ name: source-${{matrix.os}}-node-${{matrix.node}}
18
+ runs-on: ${{matrix.os}}
19
+ steps:
20
+ - uses: actions/checkout@v4.1.1
21
+ - uses: actions/setup-node@v4.0.2
22
+ with:
23
+ node-version: ${{matrix.node}}
24
+ - uses: pnpm/action-setup@v3.0.0
25
+ with:
26
+ version: '8'
27
+ if: ${{ matrix.node >= 18 || matrix.node == 'latest' }}
28
+ - run: pnpm install
29
+ - run: pnpm test
30
+ coverage:
31
+ needs: source
32
+ name: coverage-ubuntu-latest-node-latest
33
+ runs-on: ubuntu-latest
34
+ steps:
35
+ - uses: actions/checkout@v4.1.1
36
+ - uses: actions/setup-node@v4.0.2
37
+ with:
38
+ node-version: latest
39
+ - uses: pnpm/action-setup@v3.0.0
40
+ with:
41
+ version: '8'
42
+ - run: pnpm install
43
+ - run: pnpm do-ci
44
+ - uses: coverallsapp/github-action@v2.2.3
45
+ with:
46
+ github-token: ${{secrets.GITHUB_TOKEN}}
47
+ file: coverage/lcov.txt
48
+ format: lcov
package/CHANGELOG.md ADDED
@@ -0,0 +1,33 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
+
5
+ ### 0.0.1 (2025-06-14)
6
+
7
+
8
+ ### Features
9
+
10
+ * Functioning? ([8994385](https://github.com/Anadian/cno-bedrock/commit/8994385beaf11e870a27929d5dcb2c2f30cdd0b5))
11
+
12
+
13
+ ### Chores
14
+
15
+ * Updated GitHub Actions. ([e1e4a3c](https://github.com/Anadian/cno-bedrock/commit/e1e4a3cd662e1b9e0a793d249c55d40bd8380d50))
16
+
17
+
18
+ ### Continuous Integration
19
+
20
+ * Basic tests. ([b8807c1](https://github.com/Anadian/cno-bedrock/commit/b8807c1ececd838799bfea344c00678e947f5d7a))
21
+
22
+
23
+ ### Refactoring
24
+
25
+ * Cleaned code, deleted commented-out stuff. ([3c259ee](https://github.com/Anadian/cno-bedrock/commit/3c259ee08f04c63c6cc34be9793fd603668a15fc))
26
+
27
+
28
+ ### Documentation
29
+
30
+ * Added a lot of documentation comments. ([6b18aca](https://github.com/Anadian/cno-bedrock/commit/6b18aca3a7648f6016d2ab2058d550e2e62dd710))
31
+ * Fixed readme. ([4b657fc](https://github.com/Anadian/cno-bedrock/commit/4b657fcf15c73bab15d7acb3096e115c54b35a50))
32
+ * Improved documentation generation. ([f254631](https://github.com/Anadian/cno-bedrock/commit/f25463179e71f105ecb096094251b6bffd76c78a))
33
+ * Updated README.md; ready for first release. ([b1c067a](https://github.com/Anadian/cno-bedrock/commit/b1c067abb7c1c482ecfc5c33f34e6238990c0984))
package/LICENSE ADDED
@@ -0,0 +1,16 @@
1
+ MIT ©2025 Anadian
2
+ Copyright 2025 Anadian
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this
4
+ software and associated documentation files (the "Software"), to deal in the Software
5
+ without restriction, including without limitation the rights to use, copy, modify,
6
+ merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
7
+ permit persons to whom the Software is furnished to do so, subject to the following
8
+ conditions:
9
+ The above copyright notice and this permission notice shall be included in all copies
10
+ or substantial portions of the Software.
11
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
12
+ INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
13
+ PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
14
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
15
+ CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
16
+ OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # cno-bedrock
2
+ [![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
3
+ [![Semantic Versioning 2.0.0](https://img.shields.io/badge/semver-2.0.0-brightgreen?style=flat-square)](https://semver.org/spec/v2.0.0.html)
4
+ [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg?style=flat-square)](https://conventionalcommits.org)
5
+ [![License](https://img.shields.io/github/license/Anadian/cno-bedrock)](https://github.com/Anadian/cno-bedrock/blob/main/LICENSE)
6
+ [![ci](https://github.com/Anadian/cno-bedrock/actions/workflows/ci.yml/badge.svg)](https://github.com/Anadian/cno-bedrock/actions/workflows/ci.yml)
7
+ [![NPM Version](https://img.shields.io/npm/v/cno-bedrock)](https://www.npmjs.com/package/cno-bedrock)
8
+ [![Coverage Status](https://coveralls.io/repos/github/Anadian/cno-bedrock/badge.svg?branch=main)](https://coveralls.io/github/Anadian/cno-bedrock?branch=main)
9
+
10
+ > Micropackage: a test bed for various small pieces of reusable code.
11
+ # Table of Contents
12
+ - [Background](#Background)
13
+ - [Install](#Install)
14
+ - [Usage](#Usage)
15
+ - [API](#API)
16
+ - [Contributing](#Contributing)
17
+ - [License](#License)
18
+ # Background
19
+ # Install
20
+ Available on the [npm registry](https://www.npmjs.com/package/cno-bedrock) as `cno-bedrock`. Add it to a project using [pnpm](https://pnpm.io/cli/add):
21
+ ```sh
22
+ pnpm add --save cno-read-by-block
23
+ ```
24
+ It can, of course, also be installed by [npm](https://docs.npmjs.com/cli/v8/commands/npm-install) or [yarn](https://yarnpkg.com/getting-started/usage) using the normal methods.
25
+ # Usage
26
+ ```js
27
+ import Namespace from 'cno-bedrock'; // Default export is a full "namespace".
28
+ import { OneFunction } from 'cno-bedrock'; // To just export a single function.
29
+ ```
30
+ # API
31
+ See [docs directory](docs/src) for full API.
32
+ # Contributing
33
+ Changes are tracked in [CHANGELOG.md](CHANGELOG.md).
34
+ # License
35
+ MIT ©2025 Anadian
36
+
37
+ SEE LICENSE IN [LICENSE](LICENSE)
38
+
39
+ [![Creative Commons License](https://i.creativecommons.org/l/by-sa/4.0/88x31.png)](http://creativecommons.org/licenses/by-sa/4.0/)This project's documentation is licensed under a [Creative Commons Attribution-ShareAlike 4.0 International License](http://creativecommons.org/licenses/by-sa/4.0/).
@@ -0,0 +1,72 @@
1
+ {
2
+ "name": "ci",
3
+ on: ["push", "pull_request"],
4
+ jobs: {
5
+ source: {
6
+ strategy: {
7
+ matrix: {
8
+ os: ['ubuntu-latest', 'macos-latest', 'windows-latest'],
9
+ node: [ '18', '20', 'latest' ]
10
+ }
11
+ },
12
+ name: 'source-${{matrix.os}}-node-${{matrix.node}}',
13
+ 'runs-on': '${{matrix.os}}',
14
+ steps: [
15
+ { uses: 'actions/checkout@v4.1.1' },
16
+ {
17
+ uses: 'actions/setup-node@v4.0.2',
18
+ with: {
19
+ 'node-version': '${{matrix.node}}'
20
+ }
21
+ },
22
+ {
23
+ uses: 'pnpm/action-setup@v3.0.0',
24
+ with: {
25
+ version: '8'
26
+ },
27
+ if: "${{ matrix.node >= 18 || matrix.node == 'latest' }}"
28
+ },
29
+ {
30
+ run: 'pnpm install'
31
+ },
32
+ {
33
+ run: 'pnpm test'
34
+ }
35
+ ]
36
+ },
37
+ coverage: {
38
+ needs: 'source',
39
+ name: 'coverage-ubuntu-latest-node-latest',
40
+ 'runs-on': 'ubuntu-latest',
41
+ steps: [
42
+ { uses: 'actions/checkout@v4.1.1' },
43
+ {
44
+ uses: 'actions/setup-node@v4.0.2',
45
+ with: {
46
+ 'node-version': 'latest'
47
+ }
48
+ },
49
+ {
50
+ uses: 'pnpm/action-setup@v3.0.0',
51
+ with: {
52
+ version: '8'
53
+ },
54
+ },
55
+ {
56
+ run: 'pnpm install'
57
+ },
58
+ {
59
+ run: 'pnpm do-ci'
60
+ },
61
+ {
62
+ uses: 'coverallsapp/github-action@v2.2.3',
63
+ with: {
64
+ "github-token": '${{secrets.GITHUB_TOKEN}}',
65
+ "file": 'coverage/lcov.txt',
66
+ "format": 'lcov'
67
+ }
68
+ }
69
+ ]
70
+ }
71
+ }
72
+ }
@@ -0,0 +1,158 @@
1
+
2
+ # [cno-assert.js](src/cno-assert.js)
3
+ > Custom assert functions.
4
+
5
+ Author: Anadian
6
+
7
+ Code license: MIT
8
+ ```
9
+ Copyright 2024 Anadian
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this
11
+ software and associated documentation files (the "Software"), to deal in the Software
12
+ without restriction, including without limitation the rights to use, copy, modify,
13
+ merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
14
+ permit persons to whom the Software is furnished to do so, subject to the following
15
+ conditions:
16
+ The above copyright notice and this permission notice shall be included in all copies
17
+ or substantial portions of the Software.
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
19
+ INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
20
+ PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
22
+ CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
23
+ OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+ ```
25
+ Documentation License: [![Creative Commons License](https://i.creativecommons.org/l/by-sa/4.0/88x31.png)](http://creativecommons.org/licenses/by-sa/4.0/)
26
+ > The source-code comments and documentation are written in [GitHub Flavored Markdown](https://github.github.com/gfm/).
27
+
28
+
29
+ ## Functions
30
+
31
+ ### assertSameType
32
+ > Throws if actual's type is not the same as expected's, according to a strict `typeof` comparison.
33
+
34
+ #### Parametres
35
+ | name | type | description |
36
+ | --- | --- | --- |
37
+ | actual | any | The actual value. |
38
+ | expected | any | The expected value. |
39
+ | message | string | A custom message for the assertion. \[default: ''\] |
40
+
41
+ #### Throws
42
+ | code | type | condition |
43
+ | --- | --- | --- |
44
+ | 'ERR_ASSERTION_SAMETYPE' | AssertionError | Thrown if `typeof(actual) !== typeof(expected)`. |
45
+
46
+ #### History
47
+ | version | change |
48
+ | --- | --- |
49
+ | 0.0.1 | WIP |
50
+
51
+
52
+ ### assertNonstrictNotEqual
53
+ > Throws if actual and expected can be coerced to equal one another.
54
+
55
+ #### Parametres
56
+ | name | type | description |
57
+ | --- | --- | --- |
58
+ | actual | any | The actual value. |
59
+ | expected | any | The expected value. |
60
+ | message, | string | A custom message for the assertion. \[default: ''\] |
61
+
62
+ #### Throws
63
+ | code | type | condition |
64
+ | --- | --- | --- |
65
+ | 'ERR_ASSERTION_NONSTRICTNOTEQUAL' | AssertionError | Thrown if `actual == expected`. |
66
+
67
+ #### History
68
+ | version | change |
69
+ | --- | --- |
70
+ | 0.0.1 | WIP |
71
+
72
+
73
+ ### assertStrictlyNotEqual
74
+ > Throws if actual is not the same type as expected or is the value as expected.
75
+
76
+ #### Parametres
77
+ | name | type | description |
78
+ | --- | --- | --- |
79
+ | actual | any | The actual value. |
80
+ | expected | any | The expected/invalid value. |
81
+ | name | string | The name of variable as a string, for a more informative auto message. \[default: ''\] |
82
+ | value | string | The expected value as a string, for a more informative auto message. \[default: ''\] |
83
+ | expectedType | string | The expected's type as a string, for a more informative auto message. \[default: ''\] |
84
+ | message | string | A custom message for the assertion. \[default: ''\] |
85
+
86
+ #### Throws
87
+ | code | type | condition |
88
+ | --- | --- | --- |
89
+ | 'ERR_ASSERTION_STRICTLYNOTEQUAL' | AssertionError | Thrown if actual is not strictly-not-equal (`=!=`) to expected. |
90
+
91
+ #### History
92
+ | version | change |
93
+ | --- | --- |
94
+ | 0.0.1 | WIP |
95
+
96
+
97
+ ### assertInstanceof
98
+ > Throws if actual is not an instance of (via `instanceof`) of expected.
99
+
100
+ #### Parametres
101
+ | name | type | description |
102
+ | --- | --- | --- |
103
+ | actual | any | The actual value. |
104
+ | expected | any | The expected value. |
105
+ | message | string | A custom message for the assertion. \[default: ''\] |
106
+
107
+ #### Throws
108
+ | code | type | condition |
109
+ | --- | --- | --- |
110
+ | 'ERR_ASSERTION_INSTANCEOF' | AssertionError | Thrown if actual is not an instance of expected. |
111
+
112
+ #### History
113
+ | version | change |
114
+ | --- | --- |
115
+ | 0.0.1 | WIP |
116
+
117
+
118
+ ### assertExpectedError
119
+ > Throws if the actual error doesn't match the the object describe in expected.
120
+
121
+ #### Parametres
122
+ | name | type | description |
123
+ | --- | --- | --- |
124
+ | actual | any | The actual error. |
125
+ | expected | any | An object with a the properties 'constructor' with the constructor function used to create the error and 'code' the expected code property of the error. |
126
+ | message | string | A custom message for the assertion. \[default: ''\] |
127
+
128
+ #### Throws
129
+ | code | type | condition |
130
+ | --- | --- | --- |
131
+ | 'ERR_ASSERTION_EXPECTEDERROR' | AssertionError | Thrown if actual doesn't match the error described by expected. |
132
+
133
+ #### History
134
+ | version | change |
135
+ | --- | --- |
136
+ | 0.0.1 | WIP |
137
+
138
+
139
+ ### assertObjectsQuantitativelyEqual
140
+ > Throws if acutal doesn't have the same properties and values as expected. Compared via [lodash's `_.isEqual`](https://lodash.com/docs/4.17.15#isEqual).
141
+
142
+ #### Parametres
143
+ | name | type | description |
144
+ | --- | --- | --- |
145
+ | actual | any | The actual object. |
146
+ | expected | any | The expected object. |
147
+ | message | string | A custom message for the assertion. \[default: ''\] |
148
+
149
+ #### Throws
150
+ | code | type | condition |
151
+ | --- | --- | --- |
152
+ | 'ERR_ASSERTION_OBJECTSQUANTITATIVELYEQUAL' | AssertionError | Thrown if `_.isEqual( actual, expected )` is not true. |
153
+
154
+ #### History
155
+ | version | change |
156
+ | --- | --- |
157
+ | 0.0.1 | WIP |
158
+
@@ -0,0 +1,29 @@
1
+
2
+ # [cno-noop.js](src/cno-noop.js)
3
+ > NOOP functions.
4
+
5
+ Author: Anadian
6
+
7
+ Code license: MIT
8
+ ```
9
+ Copyright 2024 Anadian
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this
11
+ software and associated documentation files (the "Software"), to deal in the Software
12
+ without restriction, including without limitation the rights to use, copy, modify,
13
+ merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
14
+ permit persons to whom the Software is furnished to do so, subject to the following
15
+ conditions:
16
+ The above copyright notice and this permission notice shall be included in all copies
17
+ or substantial portions of the Software.
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
19
+ INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
20
+ PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
22
+ CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
23
+ OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+ ```
25
+ Documentation License: [![Creative Commons License](https://i.creativecommons.org/l/by-sa/4.0/88x31.png)](http://creativecommons.org/licenses/by-sa/4.0/)
26
+ > The source-code comments and documentation are written in [GitHub Flavored Markdown](https://github.github.com/gfm/).
27
+
28
+
29
+ ## Functions
@@ -0,0 +1,61 @@
1
+
2
+ # [cno-options.js](src/cno-options.js)
3
+ > Implements functions and defaults for `input_options`-type parametres.
4
+
5
+ Author: Anadian
6
+
7
+ Code license: MIT
8
+ ```
9
+ Copyright 2025 Anadian
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this
11
+ software and associated documentation files (the "Software"), to deal in the Software
12
+ without restriction, including without limitation the rights to use, copy, modify,
13
+ merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
14
+ permit persons to whom the Software is furnished to do so, subject to the following
15
+ conditions:
16
+ The above copyright notice and this permission notice shall be included in all copies
17
+ or substantial portions of the Software.
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
19
+ INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
20
+ PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
22
+ CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
23
+ OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+ ```
25
+ Documentation License: [![Creative Commons License](https://i.creativecommons.org/l/by-sa/4.0/88x31.png)](http://creativecommons.org/licenses/by-sa/4.0/)
26
+ > The source-code comments and documentation are written in [GitHub Flavored Markdown](https://github.github.com/gfm/).
27
+
28
+
29
+ ## Functions
30
+
31
+ ### deriveOptions
32
+ > Derives and returns the final runtime options.
33
+
34
+ #### Parametres
35
+ | name | type | description |
36
+ | --- | --- | --- |
37
+ | input_options | object | Run-time options. |
38
+ | default_options | object | The default options to be derived against. |
39
+ | dynamic_function | function | A function which receives an options object as an argument and returns a modified options object; used for dynamic defaults derived from other options. \[default: null\] |
40
+ | standard_options | boolean | Whether to include the defaults for the standard options \(see below\). \[default: true\] |
41
+
42
+ ##### Stanard Options
43
+ > Available via `deriveOptions.STANDARD_OPTIONS`.
44
+ | name | type | default | description |
45
+ | --- | --- | --- | --- |
46
+ | noop | boolean | false | Skip primary functionality. |
47
+ | noDefaults | boolean | false | Don't apply static default options. |
48
+ | noDynamic | boolean | false | Don't apply dynamic default options. |
49
+ | logFunction | function | [returnNull](#returnNull) | A function to use for logging. \[Default: [returnNULL](#returnNull)\] |
50
+ | validationFunction | function | [returnTrue](#returnTrue) | A function for validating the contents of the final options, returning `true` meaning things proceed. \[Default: [returnTrue](#returnTrue)\] |
51
+
52
+ #### Returns
53
+ | type | description |
54
+ | --- | --- |
55
+ | object | Returns the final options object. |
56
+
57
+ #### History
58
+ | version | change |
59
+ | --- | --- |
60
+ | 0.0.1 | WIP |
61
+
@@ -0,0 +1,145 @@
1
+
2
+ # [cno-time.js](src/cno-time.js)
3
+ > `cno-time`: A micropackage with time-related utilities.
4
+
5
+ Author: Anadian
6
+
7
+ Code license: MIT
8
+ ```
9
+ Copyright 2025 Anadian
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this
11
+ software and associated documentation files (the "Software"), to deal in the Software
12
+ without restriction, including without limitation the rights to use, copy, modify,
13
+ merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
14
+ permit persons to whom the Software is furnished to do so, subject to the following
15
+ conditions:
16
+ The above copyright notice and this permission notice shall be included in all copies
17
+ or substantial portions of the Software.
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
19
+ INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
20
+ PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
22
+ CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
23
+ OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+ ```
25
+ Documentation License: [![Creative Commons License](https://i.creativecommons.org/l/by-sa/4.0/88x31.png)](http://creativecommons.org/licenses/by-sa/4.0/)
26
+ > The source-code comments and documentation are written in [GitHub Flavored Markdown](https://github.github.com/gfm/).
27
+
28
+
29
+ ## Functions
30
+
31
+ ### getNowISO
32
+ > Returns 'now' as an ISO 8601 string.
33
+
34
+ #### Returns
35
+ | type | description |
36
+ | --- | --- |
37
+ | string | The ISO8601/RFC3339-formatted string. |
38
+
39
+ #### History
40
+ | version | change |
41
+ | --- | --- |
42
+ | 0.0.1 | WIP |
43
+
44
+
45
+ ### getDateFromUnixTimestamp
46
+ > Returns a new [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) from a Unix-style millisecond timestamp.
47
+
48
+ #### Parametres
49
+ | name | type | description |
50
+ | --- | --- | --- |
51
+ | unix_timestamp | number | Timestamp in milliseconds. |
52
+
53
+ #### Returns
54
+ | type | description |
55
+ | --- | --- |
56
+ | Date | The new Date object. |
57
+
58
+ #### History
59
+ | version | change |
60
+ | --- | --- |
61
+ | 0.0.1 | WIP |
62
+
63
+
64
+ ### getISOStringFromUnixTimestamp
65
+ > Returns an ISO string from a Unix-style millisecond timestamp.
66
+
67
+ #### Parametres
68
+ | name | type | description |
69
+ | --- | --- | --- |
70
+ | unix_timestamp | number | Timestamp in milliseconds. |
71
+
72
+ #### Returns
73
+ | type | description |
74
+ | --- | --- |
75
+ | string | The ISO8601/RFC3339 string. |
76
+
77
+ #### History
78
+ | version | change |
79
+ | --- | --- |
80
+ | 0.0.1 | WIP |
81
+
82
+
83
+ ### Clock
84
+ > Creates a new clock object.
85
+
86
+ #### Parametres
87
+ | name | type | description |
88
+ | --- | --- | --- |
89
+ | input_options | object | Run-time options. \[default: {}\] |
90
+
91
+ ##### `options` Properties
92
+ | name | type | default | description |
93
+ | --- | --- | --- | --- |
94
+ | getFunction | function | process.hrtime.bigint | The function to use to get the current timestamp. |
95
+ | granularity | number | 0.000000001 | A number representing the precision of the clock get function relative to seconds. |
96
+
97
+ #### Returns
98
+ | type | description |
99
+ | --- | --- |
100
+ | object | Returns the new Clock object. |
101
+
102
+ #### Throws
103
+ | code | type | condition |
104
+ | --- | --- | --- |
105
+ | 'ERR_INVALID_ARG_TYPE' | TypeError | Thrown if a given argument isn't of the correct type. |
106
+
107
+ #### History
108
+ | version | change |
109
+ | --- | --- |
110
+ | 0.0.1 | WIP |
111
+
112
+
113
+ ### getStringFromDurationOptions
114
+ > Returns a formatted string depending on the options specified.
115
+
116
+ #### Parametres
117
+ | name | type | description |
118
+ | --- | --- | --- |
119
+ | input_options | object | Run-time options. \[default: {}\] |
120
+
121
+ ##### `options` Properties
122
+ | name | type | default | description |
123
+ | --- | --- | --- | --- |
124
+ | duration | number | Number.NaN | The duration; assumed to be in seconds unless `base` is specified. |
125
+ | seconds_per_unit | number | 1 | The base of scale for `duration`; for example: `1` mean duration is specified in seconds, `0.001` means duration is in milliseconds, `60` means duration is in minutes. |
126
+ | units_per_second | number | 1 | The inverse of `seconds_per_unit` which can also be used to derive `seconds_per_unit` via taking the reciprocal (1/`units_per_second`); ignored if `seconds_per_unit` is specified. |
127
+ | units | string|boolean | "\u205f" | A string to place between a number and its unit or a non-truthy value to omit units entirely from the formatted string. |
128
+ | separator | string|boolean | "\u2005" | A string to put between each order of magnitude or a non-truthy value to omit separation altogether. |
129
+ | applied_units | object | { hours: 'h', minutes: 'min', seconds: 's' } | An object whose properties indicate which units should be included with the property value indicating a preferred unit symbol. See [MathJS](https://mathjs.org/docs/datatypes/units.html#reference) for available units. |
130
+
131
+ #### Returns
132
+ | type | description |
133
+ | --- | --- |
134
+ | string | The formatted duration string. |
135
+
136
+ #### Throws
137
+ | code | type | condition |
138
+ | --- | --- | --- |
139
+ | 'ERR_INVALID_ARG_TYPE' | TypeError | Thrown if a given argument isn't of the correct type. |
140
+
141
+ #### History
142
+ | version | change |
143
+ | --- | --- |
144
+ | 0.0.1 | WIP |
145
+
@@ -0,0 +1,76 @@
1
+
2
+ # [cno-utility.js](src/cno-utility.js)
3
+ > Various utilities for debugging and common tasks.
4
+
5
+ Author: Anadian
6
+
7
+ Code license: MIT
8
+ ```
9
+ Copyright 2024 Anadian
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this
11
+ software and associated documentation files (the "Software"), to deal in the Software
12
+ without restriction, including without limitation the rights to use, copy, modify,
13
+ merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
14
+ permit persons to whom the Software is furnished to do so, subject to the following
15
+ conditions:
16
+ The above copyright notice and this permission notice shall be included in all copies
17
+ or substantial portions of the Software.
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
19
+ INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
20
+ PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
22
+ CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
23
+ OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
+ ```
25
+ Documentation License: [![Creative Commons License](https://i.creativecommons.org/l/by-sa/4.0/88x31.png)](http://creativecommons.org/licenses/by-sa/4.0/)
26
+ > The source-code comments and documentation are written in [GitHub Flavored Markdown](https://github.github.com/gfm/).
27
+
28
+
29
+ ## Functions
30
+
31
+ ### annotateThis
32
+ > Adds some basic information, UID and creation time, to `this`, useful for debugging.
33
+
34
+ #### History
35
+ | version | change |
36
+ | --- | --- |
37
+ | 0.0.1 | WIP |
38
+
39
+
40
+ ### inspThis
41
+ > [Inspects](https://nodejs.org/api/util.html#utilinspectobject-options) `this` with some more concise defaults.
42
+
43
+ #### Parametres
44
+ | name | type | description |
45
+ | --- | --- | --- |
46
+ | options | object | Overwrite options to pass to inspect. \[default: null\] |
47
+
48
+ #### History
49
+ | version | change |
50
+ | --- | --- |
51
+ | 0.0.1 | WIP |
52
+
53
+
54
+ ### getAnnotatedObject
55
+ > [`annotateThis`](#annotateThis) but modifies and returns a copy of the given input object.
56
+
57
+ #### Parametres
58
+ | name | type | description |
59
+ | --- | --- | --- |
60
+ | input_object | object | The object to add the properties to. \[default: null\] |
61
+
62
+ #### Returns
63
+ | type | description |
64
+ | --- | --- |
65
+ | object | The freshly-annotated object. |
66
+
67
+ #### Throws
68
+ | code | type | condition |
69
+ | --- | --- | --- |
70
+ | 'ERR_INVALID_ARG_TYPE' | TypeError | Thrown if a given argument isn't of the correct type. |
71
+
72
+ #### History
73
+ | version | change |
74
+ | --- | --- |
75
+ | 0.0.1 | WIP |
76
+