0.12.0 • Published 6 years ago

smalltypes v0.12.0

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

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

0.12.0

6 years ago

0.11.0

6 years ago

0.10.0

6 years ago

0.9.0

6 years ago

0.8.0

6 years ago

0.7.0

6 years ago

0.6.1

6 years ago

0.6.0

6 years ago

0.5.1

6 years ago

0.5.0

6 years ago

0.4.4

6 years ago

0.4.3

6 years ago

0.4.2

6 years ago

0.4.1

6 years ago

0.4.0

6 years ago

0.3.12

6 years ago

0.3.11

6 years ago

0.3.10

6 years ago

0.3.9

6 years ago

0.3.8

6 years ago

0.3.7

6 years ago

0.3.6

6 years ago

0.3.5

6 years ago

0.3.4

6 years ago

0.3.3

6 years ago

0.3.2

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.0

6 years ago