Skip to content

Commit a58766a

Browse files
committed
Drop support for Node versions < v12.17
Convert to ECMAScript Modules Upgrade deps, dates, CI
1 parent d3a50a0 commit a58766a

28 files changed

Lines changed: 1284 additions & 6890 deletions

.github/workflows/node.js.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,20 @@ on:
1111
jobs:
1212
build:
1313

14-
runs-on: ubuntu-latest
14+
runs-on: ${{ matrix.os }}
1515

1616
strategy:
1717
matrix:
18-
node-version: [10, 12, 14, 16, 17]
18+
os: [ubuntu-latest, windows-latest]
19+
node-version: [12, 14, 16, 18, 20, 22]
1920

2021
steps:
21-
- uses: actions/checkout@v2
22+
- uses: actions/checkout@v4
2223
- name: Use Node.js ${{ matrix.node-version }}
23-
uses: actions/setup-node@v2
24+
uses: actions/setup-node@v4
2425
with:
2526
node-version: ${{ matrix.node-version }}
2627
cache: 'npm'
27-
- run: npm ci
28+
- run: npm install
29+
- run: npm i -g @75lb/nature
2830
- run: npm run test:ci

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2015-22 Lloyd Brookes <75pound@gmail.com>
3+
Copyright (c) 2015-24 Lloyd Brookes <75pound@gmail.com>
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,6 @@ Old browser (adds `window.sortArray`):
200200

201201
* * *
202202

203-
&copy; 2015-22 Lloyd Brookes \<75pound@gmail.com\>.
203+
&copy; 2015-24 Lloyd Brookes \<75pound@gmail.com\>.
204204

205-
Isomorphic test suite by [test-runner](https://github.com/test-runner-js/test-runner) and [web-runner](https://github.com/test-runner-js/web-runner). Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).
205+
Tested by [test-runner](https://github.com/test-runner-js/test-runner). Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,6 @@ Old browser (adds `window.sortArray`):
225225

226226
* * *
227227

228-
&copy; 2015-22 Lloyd Brookes \<75pound@gmail.com\>.
228+
&copy; 2015-24 Lloyd Brookes \<75pound@gmail.com\>.
229229

230-
Isomorphic test suite by [test-runner](https://github.com/test-runner-js/test-runner) and [web-runner](https://github.com/test-runner-js/web-runner). Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).
230+
Tested by [test-runner](https://github.com/test-runner-js/test-runner). Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).

dist/index.mjs renamed to dist/index.cjs

Lines changed: 52 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
/**
24
* Takes any input and guarantees an array back.
35
*
@@ -60,15 +62,15 @@ function arrayify (input) {
6062
* @module typical
6163
* @typicalname t
6264
* @example
63-
* const t = require('typical')
65+
* import * as t from 'typical'
6466
* const allDefined = array.every(t.isDefined)
6567
*/
6668

6769
/**
68-
* Returns true if input is a number. It is a more reasonable alternative to `typeof n` which returns `number` for `NaN` and `Infinity`.
70+
* Returns true if input is a number (including infinity). It is a more reasonable alternative to `typeof n` which returns `number` for `NaN`.
6971
*
70-
* @param {*} - the input to test
71-
* @returns {boolean}
72+
* @param {*} n - The input to test
73+
* @returns {boolean} `true` if input is a number
7274
* @static
7375
* @example
7476
* > t.isNumber(0)
@@ -86,16 +88,44 @@ function arrayify (input) {
8688
* > t.isNumber(NaN)
8789
* false
8890
* > t.isNumber(Infinity)
89-
* false
91+
* true
9092
*/
9193
function isNumber (n) {
94+
return !isNaN(parseFloat(n))
95+
}
96+
97+
/**
98+
* Returns true if input is a finite number. Identical to `isNumber` beside excluding infinity.
99+
*
100+
* @param {*} n - The input to test
101+
* @returns {boolean}
102+
* @static
103+
* @example
104+
* > t.isFiniteNumber(0)
105+
* true
106+
* > t.isFiniteNumber(1)
107+
* true
108+
* > t.isFiniteNumber(1.1)
109+
* true
110+
* > t.isFiniteNumber(0xff)
111+
* true
112+
* > t.isFiniteNumber(0644)
113+
* true
114+
* > t.isFiniteNumber(6.2e5)
115+
* true
116+
* > t.isFiniteNumber(NaN)
117+
* false
118+
* > t.isFiniteNumber(Infinity)
119+
* false
120+
*/
121+
function isFiniteNumber (n) {
92122
return !isNaN(parseFloat(n)) && isFinite(n)
93123
}
94124

95125
/**
96126
* A plain object is a simple object literal, it is not an instance of a class. Returns true if the input `typeof` is `object` and directly decends from `Object`.
97127
*
98-
* @param {*} - the input to test
128+
* @param {*} input - The input to test
99129
* @returns {boolean}
100130
* @static
101131
* @example
@@ -125,7 +155,7 @@ function isPlainObject (input) {
125155
/**
126156
* An array-like value has all the properties of an array yet is not an array instance. An example is the `arguments` object. Returns `true`` if the input value is an object, not `null`` and has a `length` property set with a numeric value.
127157
*
128-
* @param {*} - the input to test
158+
* @param {*} input - The input to test
129159
* @returns {boolean}
130160
* @static
131161
* @example
@@ -140,7 +170,7 @@ function isArrayLike (input) {
140170

141171
/**
142172
* Returns true if the typeof input is `'object'` but not null.
143-
* @param {*} - the input to test
173+
* @param {*} input - The input to test
144174
* @returns {boolean}
145175
* @static
146176
*/
@@ -150,7 +180,7 @@ function isObject (input) {
150180

151181
/**
152182
* Returns true if the input value is defined.
153-
* @param {*} - the input to test
183+
* @param {*} input - The input to test
154184
* @returns {boolean}
155185
* @static
156186
*/
@@ -160,7 +190,7 @@ function isDefined (input) {
160190

161191
/**
162192
* Returns true if the input value is undefined.
163-
* @param {*} - the input to test
193+
* @param {*} input - The input to test
164194
* @returns {boolean}
165195
* @static
166196
*/
@@ -170,27 +200,27 @@ function isUndefined (input) {
170200

171201
/**
172202
* Returns true if the input value is null.
173-
* @param {*} - the input to test
203+
* @param {*} input - The input to test
174204
* @returns {boolean}
175205
* @static
176206
*/
177207
function isNull (input) {
178-
return input === null
208+
return input === null
179209
}
180210

181211
/**
182212
* Returns true if the input value is not one of `undefined`, `null`, or `NaN`.
183-
* @param {*} - the input to test
213+
* @param {*} input - The input to test
184214
* @returns {boolean}
185215
* @static
186216
*/
187217
function isDefinedValue (input) {
188-
return isDefined(input) && !isNull(input) && !Number.isNaN(input)
218+
return isDefined(input) && !isNull(input) && !Number.isNaN(input)
189219
}
190220

191221
/**
192222
* Returns true if the input value is an ES2015 `class`.
193-
* @param {*} - the input to test
223+
* @param {*} input - The input to test
194224
* @returns {boolean}
195225
* @static
196226
*/
@@ -204,7 +234,7 @@ function isClass (input) {
204234

205235
/**
206236
* Returns true if the input is a string, number, symbol, boolean, null or undefined value.
207-
* @param {*} - the input to test
237+
* @param {*} input - The input to test
208238
* @returns {boolean}
209239
* @static
210240
*/
@@ -224,7 +254,7 @@ function isPrimitive (input) {
224254

225255
/**
226256
* Returns true if the input is a Promise.
227-
* @param {*} - the input to test
257+
* @param {*} input - The input to test
228258
* @returns {boolean}
229259
* @static
230260
*/
@@ -240,7 +270,7 @@ function isPromise (input) {
240270

241271
/**
242272
* Returns true if the input is an iterable (`Map`, `Set`, `Array`, Generator etc.).
243-
* @param {*} - the input to test
273+
* @param {*} input - The input to test
244274
* @returns {boolean}
245275
* @static
246276
* @example
@@ -290,7 +320,7 @@ function isIterable (input) {
290320

291321
/**
292322
* Returns true if the input value is a string. The equivalent of `typeof input === 'string'` for use in funcitonal contexts.
293-
* @param {*} - the input to test
323+
* @param {*} input - The input to test
294324
* @returns {boolean}
295325
* @static
296326
*/
@@ -300,7 +330,7 @@ function isString (input) {
300330

301331
/**
302332
* Returns true if the input value is a function. The equivalent of `typeof input === 'function'` for use in funcitonal contexts.
303-
* @param {*} - the input to test
333+
* @param {*} input - The input to test
304334
* @returns {boolean}
305335
* @static
306336
*/
@@ -310,6 +340,7 @@ function isFunction (input) {
310340

311341
var t = {
312342
isNumber,
343+
isFiniteNumber,
313344
isPlainObject,
314345
isArrayLike,
315346
isObject,
@@ -420,4 +451,4 @@ function getCompareFunc (options = {}) {
420451
}
421452
}
422453

423-
export default sortArray;
454+
module.exports = sortArray;

0 commit comments

Comments
 (0)