Joel Purra
de0ddd5355
WIP link to assertions in readme
2020-01-21 18:42:29 +01:00
Joel Purra
bad42357de
WIP output type of value which failed an assertion
2020-01-21 18:41:02 +01:00
Joel Purra
1e89fb4d9c
Add assertion type guards
...
Uses the typescript v3.7 feature `asserts value is T` to create `assert` variants of the `is` type guards. The assertions are used to narrow types at compile time, and to throw `TypeError` at runtime for values which are not of the correct type.
```typescript
import {assert} from '@sindresorhus/is';
assert.string(foo);
```
- Each method in `is` is wrapped and mirrored in `assert`.
- Tests for `is` are duplicated for `assert`.
Notes
- The explicit typing in `interface Assert` is required for typescript to acknowledge the assertions.
- Due to the assertions requiring explicit typing, using ` property for is.assert.string()` (and so on) would require using `namespace is`, which was removed in #78 . This also means that `assert` needs to be exported separately.
- Custom descriptions are used to enhance some assertion error messages. The value is not included in the error message.
- Could perhaps use Node.js' fitting `AssertionError` on the server-side, but it would require an `import`.
Fixes #91 .
See
- https://github.com/sindresorhus/is/issues/91
- https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#assertion-functions
- https://github.com/microsoft/TypeScript/pull/32695
2020-01-21 18:02:59 +01:00
Joel Purra
c842cc260f
Upgrade dependencies ( #101 )
2020-01-21 23:56:44 +07:00
Sindre Sorhus
aeb3f74d65
Make the NodeStream type more accurate
2019-11-13 16:06:18 +07:00
Sindre Sorhus
c25b606c3b
Improve the type assertion for is.asyncFunction
2019-11-07 16:37:36 +07:00
Sindre Sorhus
af6b03d67f
Require Node.js 10
2019-11-07 15:58:29 +07:00
Blaine Bublitz
0cc82c583e
Fix a readme link ( #96 )
2019-10-31 11:20:49 +07:00
Sindre Sorhus
8ff75abfff
Tidelift tasks
2019-10-30 20:01:23 +07:00
Sindre Sorhus
e7277de849
1.2.0
2019-10-04 11:39:58 +07:00
Sindre Sorhus
3f2caa4835
Revert "Bundle the required DOM types ( #93 )"
...
This reverts commit 7c16f20d16 .
2019-10-04 11:38:10 +07:00
Sindre Sorhus
4a63743feb
1.1.0
2019-10-03 15:00:03 +07:00
Sindre Sorhus
7c16f20d16
Bundle the required DOM types ( #93 )
...
Closes #92
2019-10-02 23:06:53 +07:00
Sindre Sorhus
0f9b8479e9
Tidelift tasks
2019-09-10 12:46:18 +07:00
Sindre Sorhus
0cbd9df6ce
Minor refactoring
2019-07-01 23:19:25 +07:00
Sindre Sorhus
e358e44dd5
1.0.0
2019-06-30 15:19:21 +07:00
Sindre Sorhus
4f4820ef2f
Meta tweaks
2019-06-30 15:18:24 +07:00
Kai Niedziela
f04dffa575
Make is.number(NaN) return false ( #90 )
...
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
2019-06-30 15:09:07 +07:00
Sindre Sorhus
ffc6ce4586
Fix linting
2019-06-15 02:12:31 +07:00
Sindre Sorhus
7bf407fbf1
Create funding.yml
2019-05-28 12:56:17 +07:00
Sindre Sorhus
878d111ae7
0.17.1
2019-05-21 16:48:34 +07:00
Sindre Sorhus
6106086a35
Revert "Drop duplicate export ( #84 )"
...
This reverts commit 28913cae88 .
Closes #89
Fixes #88
2019-05-21 16:45:07 +07:00
Sindre Sorhus
b064473589
0.17.0
2019-05-13 11:07:28 +07:00
Sindre Sorhus
04cd282265
Fix the capitalization of is.bigInt64Array and is.bigUint64Array
2019-05-13 11:04:48 +07:00
Sindre Sorhus
9bc8307770
0.16.0
2019-05-04 16:13:44 +07:00
Sindre Sorhus
2dac8e96f4
Meta tweaks
2019-05-04 16:11:43 +07:00
Vlad Frangu
dd2a91dce5
Add support for BigInt ( #87 )
2019-05-04 16:05:23 +07:00
Adam Babcock
373605e40d
Test coverage for is(value) ( #86 )
2019-04-28 15:15:11 +07:00
Sindre Sorhus
120f74ab63
Require Node.js 8
2019-04-01 04:02:25 +07:00
Sindre Sorhus
ea4204f0b4
Switch to XO for linting
2019-03-31 21:34:47 +07:00
Federico Brigante
28913cae88
Drop duplicate export ( #84 )
2019-03-14 16:32:19 +07:00
Sindre Sorhus
79144f9542
Readme tweaks
2019-02-12 14:40:44 +07:00
Sindre Sorhus
c66885b781
Add sideEffects key to package.json
2019-02-04 12:56:31 +07:00
Sindre Sorhus
0fff8265e6
Fix tests
2019-02-04 03:00:25 +07:00
Sindre Sorhus
3ec41686f7
0.15.0
2019-02-04 02:55:36 +07:00
Sindre Sorhus
2f5e03bed2
Minor tweaks
2019-02-04 02:54:30 +07:00
Sindre Sorhus
9683cd7fd9
Run TS as a require hook for tests instead of precompile
2019-02-04 02:38:38 +07:00
Sindre Sorhus
3c847be5a0
Improve the TypeScript types ( #80 )
2019-02-04 02:38:38 +07:00
Scottie Enriquez
2502442404
Rename .odd() to .oddInteger() and .even() to .evenInteger() for clarity ( #77 )
2019-02-04 02:38:38 +07:00
Sindre Sorhus
641d856b36
Stop using TypeScript namespace ( #78 )
2019-02-02 01:14:08 +07:00
Sindre Sorhus
ab586df0f9
Fix lint issue
2019-01-12 12:14:45 +07:00
Sindre Sorhus
0e1cce5d45
Fix readme typo
2019-01-11 16:34:29 +07:00
Itai Steinherz
4d0120adb7
Fix is.urlString documentation ( #76 )
2018-12-13 22:38:35 +01:00
Sindre Sorhus
6cb1d1e910
0.14.0
2018-12-13 16:58:24 +01:00
Sindre Sorhus
42fd8d3574
Use the URL global when available
2018-12-13 16:57:06 +01:00
Sindre Sorhus
844b43c9df
Improve the is.observable check ( #74 )
...
Fixes #72
2018-12-13 16:52:55 +01:00
Itai Steinherz
566f363632
Add is.urlString ( #73 )
2018-12-13 16:52:21 +01:00
Sindre Sorhus
2ee148f5a1
Meta tweaks
2018-12-13 00:58:02 +01:00
Sindre Sorhus
9df6f4ebe9
Bump TypeScript version
2018-11-30 15:14:41 +07:00
jokebookservice1
b8a9fb457c
Minor documentational correction ( #69 )
2018-11-02 23:04:44 +07:00