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

dottie

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dottie - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

11

dottie.js

@@ -93,4 +93,9 @@ (function(undefined) {

Dottie.transform = function(object, options) {
options = options || {};
options.delimiter = options.delimiter || '.';
if (Array.isArray(object)) {
return object.map(Dottie.transform);
return object.map(function(o) {
return Dottie.transform(o, options);
});
}

@@ -105,4 +110,4 @@

for (var key in object) {
if (key.indexOf('.') !== -1) {
pieces = key.split('.');
if (key.indexOf(options.delimiter) !== -1) {
pieces = key.split(options.delimiter);
piecesLength = pieces.length;

@@ -109,0 +114,0 @@ current = transformed;

{
"name": "dottie",
"version": "0.2.2",
"version": "0.2.3",
"devDependencies": {

@@ -5,0 +5,0 @@ "expect.js": "~0.2.0",

@@ -40,3 +40,4 @@ [![Build Status](https://travis-ci.org/mickhansen/dottie.js.png)](https://travis-ci.org/mickhansen/dottie.js.png)

transforms is now equal to =
// transforms is now equal to =
{

@@ -52,1 +53,18 @@ user: {

}
#### With a custom delimiter
var values = {
'user_name': 'Mick Hansen',
'user_email': 'mh@innofluence.com'
};
var transformed = dottie.transform(values, { delimiter: '_' });
// transforms is now equal to =
{
user: {
name: 'Mick Hansen',
email: 'mh@innofluence.com'
}
}

@@ -122,2 +122,28 @@ var expect = require("expect.js"),

});
});
it("supports custom delimiters", function () {
var values = {
user: {
name: 'John Doe'
},
'user_email': 'jd@foobar.com',
'user_location_country': 'Zanzibar',
'user_location_city': 'Zanzibar City',
'project_title': 'dottie'
};
var transformed = dottie.transform(values, { delimiter: '_' });
expect(transformed.user).not.to.be(undefined);
expect(transformed.user.location).not.to.be(undefined);
expect(transformed.project).not.to.be(undefined);
expect(transformed.user).to.be.an('object');
expect(transformed.user.location).to.be.an('object');
expect(transformed.project).to.be.an('object');
expect(transformed.user.email).to.equal('jd@foobar.com');
expect(transformed.user.location.city).to.equal('Zanzibar City');
expect(transformed.project.title).to.equal('dottie');
});
});
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