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

nyks

Package Overview
Dependencies
Maintainers
1
Versions
251
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nyks - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

process/parseArgs.js

2

package.json
{
"name": "nyks",
"version": "1.2.0",
"version": "1.2.1",
"description": "nodejs exupery style",

@@ -5,0 +5,0 @@ "keywords": [

'use strict';
module.exports = {
'parseargs' : require('./process/parseargs')
'parseArgs' : require('./process/parseArgs'),
'splitArgs' : require('./process/splitArgs'),
};

@@ -25,6 +25,12 @@ nyks provide a set of "missing" stuffs in nodejs basic api.

Return a hex encoded md5 hash
* require('util').parseargs(process.argv.splice(2))
## process
* require('nyks/process/parseArgs')(process.argv.splice(2))
Command line args parser, aligned on yks patterns
* require('nyks/process/splitArgs')("some string 'with escaped' content")
Split a string into whitespace separated chunks
## fs

@@ -31,0 +37,0 @@ * require('nyks/fs/deleteFolderRecursive')(path);

"use strict";
var expect = require('expect.js')
var parseargs = require('../process/parseargs')
var parseArgs = require('../process/parseArgs')
var splitArgs = require('../process/splitArgs')

@@ -12,9 +13,9 @@

it("testing parseargs", function(){
expect(parseargs(["--foo"]) ).to.eql({args : [], dict : {foo:true}});
expect(parseargs(["--foo", "bar"]) ).to.eql({args : ["bar"], dict : {foo:true}});
expect(parseargs(["bar", "--foo"]) ).to.eql({args : ["bar"], dict : {foo:true}});
expect(parseargs(["bar", "--foo", "baz"]) ).to.eql({args : ["bar", "baz"], dict : {foo:true}});
expect(parseargs(["--foo=42", "--foo=55"]) ).to.eql({args : [], dict : {foo:[42, 55]}});
expect(parseargs(["--foo=42", "--foo=55", "--foo"]) ).to.eql({args : [], dict : {foo:[42, 55, true]}});
it("testing parseArgs", function(){
expect(parseArgs(["--foo"]) ).to.eql({args : [], dict : {foo:true}});
expect(parseArgs(["--foo", "bar"]) ).to.eql({args : ["bar"], dict : {foo:true}});
expect(parseArgs(["bar", "--foo"]) ).to.eql({args : ["bar"], dict : {foo:true}});
expect(parseArgs(["bar", "--foo", "baz"]) ).to.eql({args : ["bar", "baz"], dict : {foo:true}});
expect(parseArgs(["--foo=42", "--foo=55"]) ).to.eql({args : [], dict : {foo:[42, 55]}});
expect(parseArgs(["--foo=42", "--foo=55", "--foo"]) ).to.eql({args : [], dict : {foo:[42, 55, true]}});
});

@@ -26,6 +27,21 @@

it("should drop invalid args", function(){
expect(parseargs(["-=foo", "bar"]) ).to.eql({args : ["bar"], dict : {}});
expect(parseArgs(["-=foo", "bar"]) ).to.eql({args : ["bar"], dict : {}});
});
it("should test splitArgs", function(){
expect(splitArgs("a b c d") ).to.eql(["a", "b", "c", "d"]);
expect(splitArgs("a 'b' c d") ).to.eql(["a", "b", "c", "d"]);
expect(splitArgs("a \"b\" c d") ).to.eql(["a", "b", "c", "d"]);
expect(splitArgs("a \"'b'\" c d") ).to.eql(["a", "'b'", "c", "d"]);
expect(splitArgs("a \"'b c'\" c d") ).to.eql(["a", "'b c'", "c", "d"]);
expect(splitArgs("a 'b c' c d") ).to.eql(["a", "b c", "c", "d"]);
expect(splitArgs("") ).to.eql([]);
expect(splitArgs("'foo''foobar'") ).to.eql(["foo"]);
expect(splitArgs("'foo'foobar'") ).to.eql(["foo"]);
});
});
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