From 14e0ba51d6f96de8259c6c0a3720c55510a60bd9 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Tue, 16 Aug 2016 23:07:57 +0200 Subject: [PATCH] Add documentation and changelog --- CHANGELOG.md | 9 +++++++++ README.md | 25 +++++++++++++++++++++---- 2 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..3ff618a --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,9 @@ +## 1.0.0 (August 16, 2016) + +First stable and documented release - however, the functionality or API has not changed from `0.0.1`. + +* __Documentation:__ Added documentation and a changelog. + +## 0.0.1 (April 17, 2016) + +Initial release. \ No newline at end of file diff --git a/README.md b/README.md index fba6408..2edd8a3 100644 --- a/README.md +++ b/README.md @@ -2,15 +2,17 @@ Wraps a value in an array if it isn't already one. Returns an empty array for `null` and `undefined`. +A typical usecase for this: when you have an option that accepts multiple values as an array, but you want to make the use of an array literal optional when there's only a single value to specify. + ## License [WTFPL](http://www.wtfpl.net/txt/copying/) or [CC0](https://creativecommons.org/publicdomain/zero/1.0/), whichever you prefer. A donation and/or attribution are appreciated, but not required. ## Donate -My income consists largely of donations for my projects. If this module is useful to you, consider [making a donation](http://cryto.net/~joepie91/donate.html)! +Maintaining open-source projects takes a lot of time, and the more donations I receive, the more time I can dedicate to open-source. If this module is useful to you, consider [making a donation](http://cryto.net/~joepie91/donate.html)! -You can donate using Bitcoin, PayPal, Flattr, cash-in-mail, SEPA transfers, and pretty much anything else. +You can donate using Bitcoin, PayPal, Flattr, cash-in-mail, SEPA transfers, and pretty much anything else. Thank you! ## Contributing @@ -22,8 +24,23 @@ Be aware that by making a pull request, you agree to release your modifications ## Usage -TODO +Some examples: + +```javascript +var assureArray = require("assure-array"); + +assureArray("hello world"); // ["hello world!"] +assureArray(["hello", "world"]); // ["hello", "world"] +assureArray(null); // [] +assureArray([true]); // [true] +``` ## API -TODO \ No newline at end of file +### assureArray(value) + +Ensures that the provided `value` is returned as an array. + +* If `value` is an array already, this returns the array unchanged. +* If `value` is `null` or `undefined`, this returns an empty array. +* If `value` is any other kind of value, this returns a new array containing just that one value. \ No newline at end of file