Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

arrayiffy-if-string

codsen101.3kMIT5.0.10TypeScript support: included

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

api, array, arrayiffy, cast, if, input, into, only, string, stringify, turn, validate, validation

readme

arrayiffy-if-string

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

page on codsen.com page on npm page on github Downloads per month changelog MIT Licence

Install

This package is pure ESM. If you're not ready yet, install an older version of this program, 3.14.0 (npm i arrayiffy-if-string@3.14.0).

npm i arrayiffy-if-string

Quick Take

import { strict as assert } from "assert";

import { arrayiffy } from "arrayiffy-if-string";

assert.deepEqual(arrayiffy("aaa"), ["aaa"]);

assert.deepEqual(arrayiffy(""), []);

assert.equal(arrayiffy(true), true);

assert.equal(arrayiffy(), undefined);

Documentation

Please visit codsen.com for a full description of the API.

Contributing

To report bugs or request features or assistance, raise an issue on GitHub.

Licence

MIT License.

Copyright © 2010-2025 Roy Revelt and other contributors.

Thanks to KRyan for types https://stackoverflow.com/a/71834598/3943954

ok codsen star

changelog

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

5.0.0 (2022-12-01)

BREAKING CHANGES

  • Minimum supported Node version is v14.18; we're dropping v12 support

4.1.0 (2022-08-12)

Features

4.0.14 (2022-05-04)

Fixed

4.0.0 (2021-09-09)

Features

BREAKING CHANGES

  • programs now are in ES Modules and won't work with Common JS require()

3.14.0 (2021-05-24)

Features

  • config file based major bump blacklisting (e15f9bb)

3.13.15 (2021-04-11)

Reverts

  • Revert "chore: setup refresh" (23cf206)

3.13.1 (2021-01-28)

Fixed

  • add testStats to npmignore (f3c84e9)

3.13.0 (2021-01-23)

Features

3.12.0 (2020-11-28)

Accidental version bump during migration to SourceHut. Sorry about that.

3.11.0 (2019-06-29)

Features

  • Add perf measurement, recording and historical comparison (1e70e2a)

3.10.0 (2019-01-20)

  • Various documentation and setup tweaks after we migrated to monorepo
  • Setup refresh: updated dependencies and all config files using automated tools

3.4.0 (2018-10-12)

  • Updated all dependencies and restored coverage tracking both via terminal when testing and through coveralls.io

3.3.0 (2018-06-15)

GitHub sold us out. In the meantime, we:

  • Migrated to BitBucket (to host repo + perform CI) and Codacy (for code quality audit)
  • Dropped BitHound (RIP) and Travis
  • Removed package-lock

3.2.0 (2018-05-14)

Improvements

  • Now pointing unit tests at ES Modules build, not CommonJS-one. This means, unit test coverage will be correct (higher) because there won't be any missing rows that Babel added which are impossible to cover.
  • Tweaks to ava config in package.json, properly enabling the dev Rollup builds.

3.1.0 (2018-04-29)

  • Set up Prettier
  • Removed package.lock and .editorconfig
  • Wired Rollup to remove comments from non-dev builds. This means we can now leave the console.logs in the source code — Rollup will remove them during the builds.

3.0.0 (2017-11-22)

Changes

  • Rewrote in ES modules, now serving UMD, Common JS and native ES modules builds. Bumping major just in case.
  • Removed JS Standard and switched to raw ESLint on airbnb-base preset, with no-semicolon override.

1.0.0 (2017-05-22)

  • First public release