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

pixl-tools

Package Overview
Dependencies
Maintainers
1
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pixl-tools - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

4

package.json
{
"name": "pixl-tools",
"version": "1.0.2",
"description": "A set of miscellaneous utility functions for Node.JS.",
"version": "1.0.3",
"description": "A set of miscellaneous utility functions for Node.js.",
"author": "Joseph Huckaby <jhuckaby@gmail.com>",

@@ -6,0 +6,0 @@ "homepage": "https://github.com/jhuckaby/pixl-tools",

@@ -37,2 +37,3 @@ # Overview

| [hashKeysToArray()](#hashkeystoarray) | Creates an array out of all object keys (undefined order). |
| [hashValuesToArray()](#hashvaluestoarray) | Creates an array out of all object values (undefined order). |
| [isaHash()](#isahash) | Determines if a variable is a hash (object) or not. |

@@ -43,2 +44,3 @@ | [isaArray()](#isaarray) | Determines if a variable is an array or not. |

| [mergeHashes()](#mergehashes) | Non-destructive shallow merge of two objects, return the combined one. |
| [mergeHashInto()](#mergehashinto) | Merge one hash into another (destructive). |
| [parseQueryString()](#parsequerystring) | Parse a URL query string into key/value pairs. |

@@ -144,3 +146,3 @@ | [composeQueryString()](#composequerystring) | Compose a URL query string given an object of key/value pairs. |

This function returns all the hash keys as an array. Useful for sorting and then iterating over the sorted list.
This function returns all the hash keys as an array. The values are discarded. Useful for sorting and then iterating over the sorted list.

@@ -157,2 +159,20 @@ ```javascript

## hashValuesToArray
```
ARRAY hashValuesToArray( OBJECT )
```
This function returns all the hash values as an array. The keys are discarded.
```javascript
var my_hash = { foo: "bar", baz: 12345 };
var values = Tools.hashValuesToArray( my_hash );
for (var idx = 0, len = values.length; idx < len; idx++) {
var value = values[idx];
// do something with value
}
```
## isaHash

@@ -225,2 +245,16 @@

## mergeHashInto
```
VOID mergeHashInto( OBJECT_A, OBJECT_B )
```
This function shallow-merges {OBJECT_B} into {OBJECT_A}. There is no return value. Existing keys are replaced in {OBJECT_A}.
```javascript
var hash1 = { foo: "bar" };
var hash2 = { baz: 12345 };
Tools.mergeHashInto( hash1, hash2 );
```
## parseQueryString

@@ -241,3 +275,3 @@

Please note that this is a very simple function, and you should probably use the built-in Node.JS [querystring](http://nodejs.org/api/querystring.html) module instead.
Please note that this is a very simple function, and you should probably use the built-in Node.js [querystring](http://nodejs.org/api/querystring.html) module instead.

@@ -258,3 +292,3 @@ ## composeQueryString

Please note that this is a very simple function, and you should probably use the built-in Node.JS [querystring](http://nodejs.org/api/querystring.html) module instead.
Please note that this is a very simple function, and you should probably use the built-in Node.js [querystring](http://nodejs.org/api/querystring.html) module instead.

@@ -261,0 +295,0 @@ ## findObjectsIdx

@@ -1,2 +0,2 @@

// Misc Tools for Node.JS
// Misc Tools for Node.js
// Copyright (c) 2015 Joseph Huckaby

@@ -60,4 +60,11 @@ // Released under the MIT License

hashValuesToArray: function(hash) {
// convert hash values to array (discard keys)
var arr = [];
for (var key in hash) arr.push( hash[key] );
return arr;
},
isaHash: function(arg) {
// determine if arg is a hash
// determine if arg is a hash or hash-like
return( !!arg && (typeof(arg) == 'object') && (typeof(arg.length) == 'undefined') );

@@ -110,2 +117,7 @@ },

mergeHashInto: function(a, b) {
// shallow-merge keys from b into a
for (var key in b) a[key] = b[key];
},
parseQueryString: function(url) {

@@ -116,4 +128,6 @@ // parse query string into key/value pairs and return as object

query[key] = decodeURIComponent(value);
if (query[key].match(/^\-?\d+$/)) query[key] = parseInt(query[key]);
else if (query[key].match(/^\-?\d*\.\d+$/)) query[key] = parseFloat(query[key]);
return '';
} );
} );
return query;

@@ -120,0 +134,0 @@ },

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