0.0.1 • Published 9 years ago

tsut v0.0.1

Weekly downloads
3
License
Unlicense
Repository
github
Last release
9 years ago

tsut is a set of generic utilities useful to all TypeScript programmers. It's designed to be as generic and simple as possible. The utilities are just those that should be familiar to all programmers. tsut should be useful regardless of whether you're doing client or server work, and regardless of the framework you choose to use. It does not define new data structures, just functions that are useable on their own -- so you can use it for only one utility without bringing in any baggage, and just write normal TypeScript code.

The utilities are divided into modules for better organization, but you can use a single import import * as u from "tsut" and use any function from that.

Use it

Install

npm install --save andy-hanson/tsut # Latest
npm install --save tsut # Stable

Configure

You must use "target": "es6" in your tsconfig.json.

Import

import * as u from "tsut";

Call

console.log(u.difference([1, 2, 3], [3, 1]))

The utilities

The main modules are:

ModuleFor
optionFor using Options (Option<T> = T | undefined)
functionCommon higher-order functions.
seqFor using Iterables.
asyncSeqFor using AsyncIterables.
parallelLike asyncSeq but runs operations in parallel.
asyncFor using Promises and async functions.
arrayArray helpers.
stringFor using Strings.
mapFor using Maps.
setFor using Sets.

Other modules are:

ModuleFor
miscOther useful functions.
mathFor using numbers.
rangeRanges of numbers.
tupleFor using tuples.
typesEasier typeof tests.
reflectCommon Proxys.
shimsES-next shims.
builderBuilders for data structures. Used internally by seq and asyncSeq.

Documentation is here. If that's not enough, the source code is readable, so you can dive in.

Why isn't X included?

XWhy
Data structurestypescript-collections
Random utilitieschance
Date utilitiesmoment
More math utilitiesI haven't found a good library for this.

Get Help

File an issue if you have trouble using tsut.

Contribute

  • Fork the repository.
  • npm install and npm run all (If this didn't work for you, file an issue.)
  • Make a change to a module, e.g. src/array.ts - If adding a new module, remember to add it to index.ts. Don't use a default export because that can't be re-exported.
  • Modify the corresponding file test/array.ts.
  • npm install -g mocha
  • Test your change with mocha --require test/mocha-require.js test/array.ts
  • Before committing anything: - npm run lint and fix any lint errors - npm run coverage and fix any missing coverage. - npm run doc and check that it rendered correctly.

Utility functions that are generically useful will likely be accepted.

Functions that are server-side or client-side specific, or which are only useful in certain domains (e.g. validating emails), belong in different projects.

0.0.1

9 years ago

0.0.0

9 years ago