Socket
Socket
Sign inDemoInstall

comma-separated-tokens

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

comma-separated-tokens - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

49

index.js

@@ -1,40 +0,13 @@

/**
* @author Titus Wormer
* @copyright 2016 Titus Wormer
* @license MIT
* @module comma-separated-tokens
* @fileoverview Parse and stringify comma-separated tokens.
*/
'use strict';
/* Expose. */
exports.parse = parse;
exports.stringify = stringify;
/*
* Dependencies.
*/
var trim = require('trim');
/*
* Characters.
*/
var C_COMMA = ',';
var C_SPACE = ' ';
/*
* Constants.
*/
var EMPTY = '';
/**
* Parse comma-separated tokens to an array.
*
* @param {string} value - Attribute-value to parse.
* @return {Array.<string>} - Tokens.
*/
/* Parse comma-separated tokens to an array. */
function parse(value) {

@@ -67,13 +40,6 @@ var values = [];

/**
* Compile an array to comma-separated tokens.
*
* @param {Array.<string>} values - Tokens.
* @param {Object} [options={}] - Configuration.
* @param {boolean} [options.padLeft=true] - Pad the left
* of a token with one space.
* @param {boolean} [options.padRight=false] - Pad the right
* of a token with one space.
* @return {string} - Comma-separated tokens.
*/
/* Compile an array to comma-separated tokens.
* `options.padLeft` (default: `true`) pads a space left of each
* token, and `options.padRight` (default: `false`) pads a space
* to the right of each token. */
function stringify(values, options) {

@@ -83,6 +49,3 @@ var settings = options || {};

/*
* Ensure the last empty entry is seen.
*/
/* Ensure the last empty entry is seen. */
if (values[values.length - 1] === EMPTY) {

@@ -89,0 +52,0 @@ values = values.concat(EMPTY);

32

package.json
{
"name": "comma-separated-tokens",
"version": "1.0.2",
"version": "1.0.3",
"description": "Parse and stringify comma-separated tokens",

@@ -28,15 +28,12 @@ "license": "MIT",

"devDependencies": {
"browserify": "^13.0.1",
"browserify": "^14.1.0",
"esmangle": "^1.0.1",
"nyc": "^7.0.0",
"remark-cli": "^1.0.0",
"remark-comment-config": "^4.0.0",
"remark-github": "^5.0.0",
"remark-lint": "^4.0.0",
"remark-validate-links": "^4.0.0",
"nyc": "^10.0.0",
"remark-cli": "^3.0.0",
"remark-preset-wooorm": "^2.0.0",
"tape": "^4.0.0",
"xo": "^0.16.0"
"xo": "^0.18.0"
},
"scripts": {
"build-md": "remark . --quiet --frail",
"build-md": "remark . -qfo",
"build-bundle": "browserify index.js --bare -s commaSeparatedTokens > comma-separated-tokens.js",

@@ -52,19 +49,12 @@ "build-mangle": "esmangle comma-separated-tokens.js > comma-separated-tokens.min.js",

"space": true,
"esnext": false,
"ignores": [
"comma-separated-tokens.js",
"comma-separated-tokens.min.js"
"comma-separated-tokens.js"
]
},
"remarkConfig": {
"output": true,
"plugins": [
"comment-config",
"github",
"lint",
"validate-links"
],
"settings": {
"bullet": "*"
}
"preset-wooorm"
]
}
}
# comma-separated-tokens [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov]
<!--lint disable heading-increment list-item-spacing no-duplicate-headings-->
Parse and stringify comma-separated tokens according to the [spec][].

@@ -9,3 +7,3 @@

[npm][npm-install]:
[npm][]:

@@ -18,32 +16,9 @@ ```bash

Dependencies:
```javascript
var commaSeparated = require('comma-separated-tokens');
```
Parsing:
```javascript
var values = commaSeparated.parse(' a ,b,,d d ');
commaSeparated.parse(' a ,b,,d d '); //=> ['a', 'b', '', 'd d']
commaSeparated.stringify(values); //=> 'a, b, , d d'
```
Yields:
```js
[ 'a', 'b', '', 'd d' ]
```
Compiling:
```javascript
var value = commaSeparated.stringify(values);
```
Yields:
```js
'a, b, , d d'
```
## API

@@ -53,16 +28,8 @@

Parse comma-separated tokens to an array of strings, according to the
[spec][].
Parse comma-separated tokens (`string`) to an array of strings, according
to the [spec][].
###### Parameters
* `value` (`string`) — Comma-separated tokens.
###### Returns
`Array.<string>` — List of tokens.
### `commaSeparated.stringify(values[, options])`
Compile an array of strings to comma-separated tokens.
Compile an array of strings to comma-separated tokens (`string`).
Handles empty items at start or end correctly.

@@ -72,16 +39,18 @@ Note that it’s not possible to specify initial or final

###### Parameters
###### `options`
* `values` (`Array.<string>`) — List of tokens;
* `options` (`Object`, optional):
* `padLeft` (`boolean`, default: `true`)
— Whether to pad a space before a token;
* `padRight` (`boolean`, default: `false`)
— Whether to pad a space after a token.
* `padLeft` (`boolean`, default: `true`)
— Whether to pad a space before a token;
* `padRight` (`boolean`, default: `false`)
— Whether to pad a space after a token.
## Related
###### Returns
* [`collapse-white-space`](https://github.com/wooorm/collapse-white-space)
— Replace multiple white-space characters with a single space
* [`property-information`](https://github.com/wooorm/property-information)
— Information on HTML properties
* [`space-separated-tokens`](https://github.com/wooorm/space-separated-tokens)
— Parse/stringify space-separated tokens
`string` — Comma-separated tokens.
## License

@@ -101,3 +70,3 @@

[npm-install]: https://docs.npmjs.com/cli/install
[npm]: https://docs.npmjs.com/cli/install

@@ -104,0 +73,0 @@ [license]: LICENSE

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