arrayiffy-if-string
Put non-empty strings into arrays, turn empty-ones into empty arrays. Bypass everything else.
Table of Contents
Install
npm i arrayiffy-if-string
const arrayiffy = require("require arrayiffy-if-string");
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 | 518 B |
ES module build that Webpack/Rollup understands. Untranspiled ES6 code with import /export . | module | dist/arrayiffy-if-string.esm.js | 501 B |
UMD build for browsers, transpiled, minified, containing iife 's and has all dependencies baked-in | browser | dist/arrayiffy-if-string.umd.js | 553 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));
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));
It's main purpose is to prepare the input argument options' objects. Check out check-types-mini.
⬆ back to top
Contributing
- If you see an error, raise an issue.
- If you want a new feature but can't code it up yourself, also raise an issue. Let's discuss it.
- If you tried to use this package, but something didn't work out, also raise an issue. We'll try to help.
- If you want to contribute some code, fork the monorepo via BitBucket, then write code, then file a pull request via BitBucket. We'll merge it in and release.
In monorepo, npm libraries are located in packages/
folder. Inside, the source code is located either in src/
folder (normal npm library) or in the root, cli.js
(if it's a command line application).
The npm script "dev
", the "dev": "rollup -c --dev --silent"
builds the development version retaining all console.log
s with row numbers. It's handy to have js-row-num-cli installed globally so you can automatically update the row numbers on all console.log
s.
⬆ back to top
Licence
MIT License
Copyright (c) 2015-2019 Roy Revelt and other contributors