Elm-inspired functional-programming tools in Typescript.
Compilers are great. Let the compiler do the work.
For additional information and examples, please visit cooperts.io.
Most CooperTS packages are utility packages that build on primitive functional types from festive-possum, such as Maybe, Task, Result, and Decoder types.
collections- Provides functions to work with lists in various waysdecoders- Provides useful utility decoder implementations (seejsonous)dom- Manipulate the HTML dom using Tasks (seetaskarian)environment- Provides functions to read from the execution environmentlogging- Provides a few logging functionsmaybe-adapter- Provides functions to convert to/fromMaybetypes (seemaybeasy)numbers- Parse strings into numbersurl- Provides functions to validate URLs
Other CooperTS packages provide types & patterns for developers to conform to known good standards.
appy- Provides functions to interface with HATEOAS API endpointsresource- Provides types and functions for dealing with HATEOAS REST resourcestranslations- Provides support for typed translation keys and typed React-based translation interpolation using the i18next library with a custom adaptertime- Provides interfaces and functions for dealing with time durationstime-distance- Provides interfaces and functions for dealing with distances between dates
See also the lower-level packages at festive-possum, especially:
ajaxian- A wrapper aroundXMLHttpRequestthat borrows heavily from Elmjsonous- Use Elm-inspiredDecoderfunctions to verify JSON objects match expected typesmaybeasy- Use aMaybeto represent possibly-nullish valuesnonempty-list- A list-like type that is guaranteed to never be emptypiper- Functional composition in Typescriptresulty- DefinesResult, a disjunction implementation in Typescripttaskarian- DefinesTask, a Future implementation in Typescript; like Promises, but lazy
This repo uses bun as a package manager and runtime. It is recommended to use bun for local development, as it is significantly faster than npm or yarn. Bun is also used to build the packages in this repo.
Install bun and then run the following command to install all dependencies:
bun installThen, run the following command to build all packages:
bun run buildAll packages in this repo are published to github's npm registry. You should already have your npm configured with the correct access token. Bun will use this same token to publish the packages.
Because all of the packages are frequently interdependent. Often because a package either depends on other packages or else several packages all have the same dependencies. Often, when one package is updated, all of the packages need to be updated.
For example, when a new version of jsonous is released, all of the packages that depend on jsonous need to be updated.
This is especially true for decoders, which are used in many of the packages. Since there is so much interdependence,
it is often easier to update all of the packages at once. In this example, you will want to update the version of jsonous
in all of the packages that depend on it. Then you will want to rebuild all of the packages. Finally, you will want to
bump the minor version of all the packages and then publish them.
To release a new version of all packages, run the following commands in the root of the repo:
bun run build
bun run bump:minor
bun run pubThis will build all packages, bump the minor version of all packages, and then publish all packages to the github npm registry.
Other commands of interest are:
bun run bump:patch- Bump the patch version of all packagesbun run bump:major- Bump the major version of all packagesbun run pub:dryrun- Run a dry run of the publish command to see what will be publishedbun run changed- Show which packages have changed since the last release
If only need to update a single package for some reason, all these commands can be run in an individual package directory.
So for example, if you want to update the appy package, you can run the following commands in the packages/appy directory:
bun run build
bun run bump:minor
bun run pubThis will build the appy package, bump the minor version of the appy package, and then publish the appy package to the github npm registry.
CooperTS provides a robust set of functional programming tools inspired by Elm, designed to enhance your TypeScript development experience. Whether you're working with utilities, patterns, or lower-level packages, CooperTS aims to simplify and standardize your workflow. For more details, examples, and updates, visit cooperts.io. Contributions and feedback are always welcome!