JSPM

  • Created
  • Published
  • Downloads 30313
  • Score
    100M100P100Q157632F
  • License MIT

Put non-empty strings into arrays, turn empty-ones into empty arrays. Bypass everything else.

Package Exports

  • arrayiffy-if-string

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (arrayiffy-if-string) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

arrayiffy-if-string

Put non-empty strings into arrays, turn empty-ones into empty arrays. Bypass everything else.

Minimum Node version required Build Status Coverage bitHound Overall Score bitHound Dependencies View dependencies as 2D chart bitHound Dev Dependencies Known Vulnerabilities Downloads/Month Test in browser Code style: prettier MIT License

Table of Contents

Install

npm i arrayiffy-if-string
// consume as CommonJS require:
const arrayiffy = require("require arrayiffy-if-string");
// or as an ES module:
import arrayiffy from "arrayiffy-if-string";

Here's what you'll get:

Type Key in package.json Path Size
Main export - CommonJS version, transpiled to ES5, contains require and module.exports main dist/arrayiffy-if-string.cjs.js 303 B
ES module build that Webpack/Rollup understands. Untranspiled ES6 code with import/export. module dist/arrayiffy-if-string.esm.js 286 B
UMD build for browsers, transpiled, minified, containing iife's and has all dependencies baked-in browser dist/arrayiffy-if-string.umd.js 257 B

⬆  back to top

Idea

  • If it's a non-empty string, put it into an array and return it.
  • If it's empty string, return an empty array.
  • If it's anything else, just return it.
const arrayiffy = require("arrayiffy-if-string");
var res = arrayiffy("aaa");
console.log("res = " + JSON.stringify(res, null, 4));
// => ['aaa']
const arrayiffy = require("arrayiffy-if-string");
var res = arrayiffy("");
console.log("res = " + JSON.stringify(res, null, 4));
// => []
const arrayiffy = require("arrayiffy-if-string");
var res = arrayiffy(true);
console.log("res = " + JSON.stringify(res, null, 4));
// => true

It's meant for working with settings objects. Check out check-types-mini.

⬆  back to top

Contributing

  • If you want a new feature in this package or you would like us to change some of its functionality, raise an issue on this repo.

  • If you tried to use this library but it misbehaves, or you need advice setting it up, and its readme doesn't make sense, just document it and raise an issue on this repo.

  • If you would like to add or change some features, just fork it, hack away, and file a pull request. We'll do our best to merge it quickly. Prettier is enabled, so you don't need to worry about the code style.

⬆  back to top

Licence

MIT License (MIT)

Copyright © 2018 Codsen Ltd, Roy Revelt