Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

arrayiffy-if-string

Package Overview
Dependencies
Maintainers
1
Versions
142
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arrayiffy-if-string

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

  • 3.11.32
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

arrayiffy-if-string

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

Repository is on GitLab Coverage no dependencies Downloads/Month Test in browser Code style: prettier MIT License

Table of Contents

Install

npm i arrayiffy-if-string

The default is exported, so instead of "arrayiffy" below, you can name the consumed function however you want.

Consume via a require():

const arrayiffy = require("arrayiffy-if-string");

or as an ES Module:

import arrayiffy from "arrayiffy-if-string";

or for web pages, as a production-ready minified script file (so-called "UMD build"), straight from CDN:

<script src="https://cdn.jsdelivr.net/npm/arrayiffy-if-string/dist/arrayiffy-if-string.umd.js"></script>
// in which case you get a global variable "arrayiffyIfString" which you consume like this:
const arrayiffy = arrayiffyIfString;

This package has three builds in dist/ folder:

TypeKey in package.jsonPathSize
Main export - CommonJS version, transpiled to ES5, contains require and module.exportsmaindist/arrayiffy-if-string.cjs.js518 B
ES module build that Webpack/Rollup understands. Untranspiled ES6 code with import/export.moduledist/arrayiffy-if-string.esm.js501 B
UMD build for browsers, transpiled, minified, containing iife's and has all dependencies baked-inbrowserdist/arrayiffy-if-string.umd.js555 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 main purpose is to prepare the input argument options' objects. Check out check-types-mini on npm, or on GitLab.

⬆ 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 GitLab, then write code, then file a pull request on GitLab. 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" builds the development version retaining all console.logs 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.logs.

⬆ back to top

Licence

MIT License

Copyright (c) 2015-2020 Roy Revelt and other contributors

Keywords

FAQs

Package last updated on 08 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc