This package has been deprecated

Author message:

No longer maintained

smalltypes
TypeScript icon, indicating that this package has built-in type declarations

0.12.0 • Public • Published

SmallTypes

Build Status semantic-release Commitizen friendly

codecov Maintainability Test Coverage bitHound Overall Score

Dependencies Development Dependencies Greenkeeper badge

Lines of Code Files License: MIT

NPM

Object-oriented utility framework written in TypeScript. Heavily inspired by Cactoos.

Warning: very early version. Not usable for production.

Getting started

Installing

smalltypes is available on npm. You can install it using:

npm install --save smalltypes

Documentation

Usage examples

Using random numbers, mapping values, calculating sum, rounding result, and caching value.

const randomFloat: Scalar<number> =
    new RandomizedFloat(// randomized floating point number
        new ParkMillerRandom(), // random number generator
        1,
        10
    );
new Cached(// make sure value is only computed once
    new Rounded(// round number to desired precision
        new Sum(// calculate total from iterable of numbers
            new Mapped(// map each item in an iterable to a different value
                [
                    { id: 1, value: randomFloat.value() },
                    { id: 2, value: randomFloat.value() },
                    { id: 3, value: randomFloat.value() },
                    { id: 4, value: randomFloat.value() },
                    { id: 5, value: randomFloat.value() }
                ],
                (item: { readonly value: number }): number =>
                    item.value // only want the value from each item
            )
        ),
        3
    )
).value() // calculate and retrieve value

Filtering, limiting, and mapping collection. Comparing two collections for equality.

new EqualIterables(// compare iterables for equality
    ['Hello', 'World', '!'],
    new Mapped(// map each item in an iterable to a different value
        new Limited(// limit an iterable to a certain amount of items
            new Filtered(// filter an iterable to a subset of items that match callback
                [
                    { id: 1, name: 'Hello', age: 21 },
                    { id: 2, name: 'World', age: 22 },
                    { id: 3, name: '!', age: 23 },
                    { id: 4, name: 'Not', age: 16 }
                ],
                (item: { readonly age: number }): boolean =>
                    item.age > 20 // only get items with age greater than 20
            ),
            3
        ),
        (item: { readonly name: string }): string =>
            item.name // only want the name from each item
    )
).value() // calculate and retrieve value

Contributing

Requirements

Setup

Clone the repository:

git clone https://github.com/nunof07/smalltypes.git

Change the working directoy:

cd smalltypes

Install dependencies:

npm install

Running

Main tasks:

  • npm run dev: Lint, test, and watch for changes.
  • npm run build: Build library and documentation.
  • npm run coverage: Test coverage report.
  • npm run commit: Adds and commits all current changes.

Execute npm run info for information about all available tasks.

Project structure

  • dist: Built files.
  • docs: API documentation.
  • src/main: Main source code of the library.
  • src/test: Unit tests.
  • tasks: Source code for build tasks and static integration.
  • typings: Manually specified TypeScript definition files.

Note: the Babel configuration at .babelrc is mainly used for gulp. For the Babel configuration used to build the library see how the Babel Rollup plugin is setup.

Built With

Readme

Keywords

none

Package Sidebar

Install

npm i smalltypes

Weekly Downloads

0

Version

0.12.0

License

MIT

Last publish

Collaborators

  • nunof