New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

expand-object

Package Overview
Dependencies
Maintainers
2
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

expand-object - npm Package Compare versions

Comparing version 0.4.0 to 0.4.1

27

cli.js

@@ -9,5 +9,2 @@ #!/usr/bin/env node

var stdin = require('get-stdin');
var Store = require('data-store');
var store = new Store('expand-object');
var expand = require('./index');

@@ -39,19 +36,7 @@ var pkg = require('./package.json');

function run(contents) {
if (argv.get) {
output = store.get(argv.get);
console.log(output);
return;
var output = expand(contents);
if (!argv.raw) {
output = JSON.stringify(output);
}
var output = contents;
if (argv.set) {
output = expand(argv.set);
store.set(output);
} else {
output = expand(contents);
if (!argv.raw) {
output = JSON.stringify(output);
}
}
console.log(output);

@@ -62,7 +47,7 @@ process.exit(0);

if (!process.stdin.isTTY) {
return stdin(function(contents) {
stdin(function(contents) {
run(contents);
});
} else {
run(argv._[0] || '');
}
run(argv._[0] || '');

@@ -40,2 +40,8 @@ 'use strict';

var val = arr[i];
// test for `https://foo`
if (/\w:\/\/\w/.test(val)) {
res[val] = '';
continue;
}
var re = /^((?:\w+)\.(?:\w+))[:.]((?:\w+,)+)+((?:\w+):(?:\w+))/;

@@ -139,3 +145,3 @@ var m = re.exec(val);

function expandArrayObj(str, opts) {
var m = /\w+:.*:/.exec(str);
var m = /\w+:.*?:/.exec(str);
if (!m) return expandArray(str, opts);

@@ -188,34 +194,14 @@

str = String(str);
var len = str.length, i = -1;
var segs = str.split(ch);
var len = segs.length;
var res = [];
var seg = '';
var i = -1;
while (++i < len) {
var curr = str[i];
if (curr === '/') {
seg += curr;
while ((curr = str[++i]) !== '/') {
if (i >= len) {
res.push(seg);
break;
}
seg += curr;
}
var key = segs[i];
while (key[key.length - 1] === '\\') {
key = key.slice(0, -1) + ch + segs[++i];
}
if (curr !== ch) {
if (curr === '\\' && str[i + 1] === ch) {
curr = ch;
}
seg += curr;
} else if (str[i - 1] !== '\\') {
res.push(seg);
seg = '';
}
if (i === len - 1 && seg && (str[i - 1] !== '\\')) {
res.push(seg);
seg = '';
}
res.push(key);
}

@@ -222,0 +208,0 @@ return res;

{
"name": "expand-object",
"description": "Expand a string into a JavaScript object using a simple notation. Use the CLI or as a node.js lib.",
"version": "0.4.0",
"version": "0.4.1",
"homepage": "https://github.com/jonschlinkert/expand-object",
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
"repository": "jonschlinkert/expand-object",
"bugs": "https://github.com/jonschlinkert/expand-object/issues",
"bugs": {
"bugs": "https://github.com/jonschlinkert/expand-object/issues"
},
"license": "MIT",
"files": [
"index.js",
"cli.js"
"cli.js",
"index.js"
],

@@ -26,7 +28,6 @@ "main": "index.js",

"dependencies": {
"data-store": "^0.11.1",
"get-stdin": "^5.0.0",
"is-number": "^2.0.2",
"get-stdin": "^5.0.1",
"is-number": "^2.1.0",
"minimist": "^1.2.0",
"set-value": "^0.3.0"
"set-value": "^0.3.2"
},

@@ -56,4 +57,11 @@ "devDependencies": {

"list": "expand-args"
}
},
"reflinks": [
"collapse-object"
],
"layout": "default",
"plugins": [
"gulp-format-md"
]
}
}
}

@@ -1,7 +0,36 @@

# expand-object [![NPM version](https://badge.fury.io/js/expand-object.svg)](http://badge.fury.io/js/expand-object)
# expand-object [![NPM version](https://img.shields.io/npm/v/expand-object.svg)](https://www.npmjs.com/package/expand-object) [![Build Status](https://img.shields.io/travis/jonschlinkert/expand-object.svg)](https://travis-ci.org/jonschlinkert/expand-object)
> Expand a string into a JavaScript object using a simple notation. Use the CLI or as a node.js lib.
Also see [collapse-object][], for doing the reverse of this library.
- [Install](#install)
* [Type casting](#type-casting)
- [Install](#install-1)
- [CLI](#cli)
- [node.js](#nodejs)
* [children](#children)
* [siblings](#siblings)
+ [general siblings](#general-siblings)
+ [adjacent siblings](#adjacent-siblings)
+ [difference between sibling types](#difference-between-sibling-types)
* [key-value pairs](#key-value-pairs)
* [arrays](#arrays)
- [Usage examples](#usage-examples)
- [Related projects](#related-projects)
- [Running tests](#running-tests)
- [Contributing](#contributing)
- [Author](#author)
- [License](#license)
_(TOC generated by [verb](https://github.com/verbose/verb) using [markdown-toc](https://github.com/jonschlinkert/markdown-toc))_
## Install
Install with [npm](https://www.npmjs.com/)
```sh
$ npm i expand-object --save
```
Also see [collapse-object](https://github.com/jonschlinkert/collapse-object), for doing the reverse of this library.
**Examples**

@@ -261,3 +290,3 @@

Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](/new).
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/expand-object/issues/new).

@@ -268,8 +297,8 @@ ## Author

+ [github/jonschlinkert](https://github.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
## License
Copyright © 2015 Jon Schlinkert
Copyright © 2015 [Jon Schlinkert](https://github.com/jonschlinkert)
Released under the MIT license.

@@ -279,4 +308,2 @@

_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on November 02, 2015._
[collapse-object]: https://github.com/jonschlinkert/collapse-object
_This file was generated by [verb](https://github.com/verbose/verb) on December 23, 2015._
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