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

jiggler

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jiggler - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

lib/converters/underscore.js

16

lib/field.js
function Field(name, options) {
if (typeof options === 'string') {
options = {
src: options
};
}
options = options || {};

@@ -11,11 +16,10 @@

Field.prototype.get = function(object, context, callback) {
var value = object[this.name];
if (this.src && typeof this.src === 'function') {
return this.src(object, context, callback);
}
var value = object[this.src || this.name];
if (this.formatter && value !== undefined) {
value = this.formatter(value);
}
if (this.src) {
if (typeof this.src === 'function') {
return this.src(object, context, callback);
}
}

@@ -22,0 +26,0 @@ callback(null, value);

@@ -11,2 +11,5 @@ var _ = require('underscore')

J.as = {};
J.convert = {
underscore: require('./converters/underscore')
};

@@ -13,0 +16,0 @@ /**

@@ -5,3 +5,3 @@ {

"description": "jiggler provides a simple and flexible interface for defining representations for your JavaScript objects.",
"version": "0.0.4",
"version": "0.0.5",
"repository": {

@@ -19,8 +19,9 @@ "type": "git",

"dependencies": {
"underscore": "1.3.x"
, "async": "0.1.x"
"underscore": "1.3.x",
"async": "0.1.x",
"string": "~1.7.0"
},
"devDependencies": {
"mocha": "1.7.x"
, "should": "1.2.x"
"mocha": "1.7.x",
"should": "1.2.x"
},

@@ -27,0 +28,0 @@ "optionalDependencies": {},

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

![Adventure Time Jiggler](http://a3094b75ef3de92d2032-5e0efc983ceed99b1f53c92d149fb2f5.r69.cf1.rackcdn.com/jiggler.gif)
![Adventure Time Jiggler](http://i.imgur.com/XUI33tj.gif)

@@ -3,0 +3,0 @@ *The Jiggler is © 2012 Cartoon Network*

@@ -345,2 +345,23 @@ var J = require('../lib/index')

it('should map a representation to a src property via a string argument', function(done) {
var User = function() {
this.firstName = '';
};
var user = new User();
user.firstName = 'Davos';
J.define('user_public', [
J.Field('firsty', 'firstName')
]);
J.as.user_public(user, function(err, rep) {
should.not.exist(err);
should.exist(rep);
rep.should.have.property('firsty', 'Davos');
done();
});
});
it('should represent an instance with a src function', function(done) {

@@ -475,2 +496,43 @@ var User = function() {

});
describe('converters', function(){
it('should have converters', function() {
J.should.have.property('convert');
J.convert.should.have.property('underscore');
J.convert.underscore.should.be.function;
});
it('should convert camelCase to underscore', function(done) {
var User = function() {
this.firstName = '';
this.lastName = '';
this.homeAddress = {};
this.highSchools = [];
};
var user = new User();
user.firstName = 'Davos';
user.lastName = 'Seaworth';
user.homeAddress = {
streetLine1: 'test',
streetLine2: 'test 2'
};
user.highSchools.push({
graduationYear: 2001
});
J.convert.underscore(user, function(err, rep) {
should.not.exist(err);
should.exist(rep);
rep.should.have.property('first_name', 'Davos');
rep.should.have.property('last_name', 'Seaworth');
rep.should.have.property('home_address');
rep.home_address.should.have.property('street_line1', 'test');
rep.home_address.should.have.property('street_line2', 'test 2');
rep.should.have.property('high_schools');
rep.high_schools[0].should.have.property('graduation_year', 2001);
done();
});
});
});
});
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