7.0.0-38be65f531b05ac601780ce711717449e038c856 • Published 5 years ago

@detachhead/ts-helpers v7.0.0-38be65f531b05ac601780ce711717449e038c856

Weekly downloads
71
License
ISC
Repository
github
Last release
5 years ago

ts-helpers

various typescript helper functions and utility types

npm

features

value tracking

this library includes many helper types and functions such as add, subtract, and substring which allow the values to be known at compile time

asdf

noUncheckedIndexedAccess support

the noUncheckedIndexedAccess compiler flag is epic, but there's room for improvement. for example, the following issue:

if (foo.length > 2) {
  const bar: string = foo[1] //error: string | undefined not assignable to string
}

can be solved with lengthGreaterThan

import { lengthGreaterThan } from '@detachhead/ts-helpers'

if (lengthGreaterThan(foo, 2)) {
  const bar: string = foo[1] //no error, foo is casted to [string, string]
}

there's also lengthLessThan, lengthGreaterOrEqual, etc.

most of the array functions in this library keep track of the length, mostly thanks to this TupleOf utility type

date formatter type

this library contains a helper type and function for formatting dates using the date-fns format.

const date = formatDate(new Date(), 'dd-MM-yyyy')

assert(date === '01/01/2021') //compile error, wrong date format

you can use any date format that date-fns accepts, and the FormatDate utility type will generate a template literal type to match your desired date format.

16.2.0

2 years ago

16.1.0

3 years ago

15.0.0

3 years ago

15.1.0

3 years ago

16.0.0

3 years ago

14.0.0

3 years ago

13.0.0

3 years ago

12.2.0

3 years ago

12.1.0

3 years ago

12.1.1

3 years ago

12.0.0

3 years ago

11.2.0

4 years ago

11.1.0

4 years ago

11.0.0

4 years ago

10.0.0

4 years ago

9.0.0

4 years ago

8.2.0

4 years ago

8.1.0-dev

4 years ago

8.1.0

4 years ago

8.0.0-dev

4 years ago

8.1.2

4 years ago

8.1.1

4 years ago

8.0.0

4 years ago

6.4.0-test

5 years ago

7.0.0-test4

5 years ago

6.4.0

5 years ago

7.0.0-test3

5 years ago

7.0.0-test

5 years ago

7.0.0

5 years ago

7.0.1

5 years ago

6.4.0-test2

5 years ago

6.3.0

5 years ago

6.2.0

5 years ago

6.1.0

5 years ago

6.0.0

5 years ago

5.0.0

5 years ago

4.0.0

5 years ago

3.4.0

5 years ago

3.3.0

5 years ago

3.2.0

5 years ago

3.1.0

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.2.0

5 years ago

2.1.0

5 years ago

2.0.0

5 years ago

1.1.0

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago