3.0.5 • Published 6 months ago

chaste v3.0.5

Weekly downloads
94
License
MIT
Repository
github
Last release
6 months ago

chaste

Last version Coverage Status NPM Status

Utility for type casting & data conversion.

Chaste is a tiny library for handle type casting.

Basically you stablish the output type to convert your input data, for example:

const Chaste = require('chaste')
const chaste = Chaste(String)

Now, when you provide a input value it always return the String casting version:

chaste(12)
// => '12'

By default, it's support native types (like Array, Object, Date or Error).

Also you can provide a function-type-like, for example:

const chaste = Chaste(pad)
chaste('abc', 8, '_-').should.be.equal('_-abc_-_')
// => '_-abc_-_'

As you can see, rest param are supported!

You can use it as little middleware to be sure about the value of something.

Install

$ npm install chaste --save

If you want to use in the browser (powered by Browserify):

$ bower install chaste --save

and later link in your HTML:

<script src="bower_components/chaste/dist/chaste.js"></script>

Usage

const Chaste = require('chaste')
const chaste = Chaste(String)

chaste(12)
// => '12'

API

Chaste(type)

type

Required Type: function

Factory function to create output type.

Supported types:

  • Array (Also [])
  • Object (Also {})
  • Error
  • Buffer
  • String
  • Number
  • RegExp
  • Boolean
  • Function

Notes that you can provide your own factory function as well, but it needs to create instances without using new keyword.

License

MIT © Kiko Beats

3.0.4

8 months ago

3.0.3

8 months ago

3.0.2

8 months ago

3.0.5

6 months ago

3.0.1

2 years ago

3.0.0

2 years ago

2.0.6

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

5 years ago

1.3.2

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.1

7 years ago

1.2.0

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago

0.0.0

8 years ago