dot-object 0.3.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of dot-object might be problematic. Click here for more details.

package/.npmignore ADDED
@@ -0,0 +1,6 @@
1
+ .*
2
+ *.ts
3
+ ATTIC
4
+ lib
5
+ Gruntfile.js
6
+ node_modules
package/bin/dotob ADDED
@@ -0,0 +1,84 @@
1
+ #!/usr/bin/env node
2
+ // vim: set filetype=javascript:
3
+ 'use strict';
4
+
5
+ var glob = require('glob');
6
+ var fs = require('fs');
7
+
8
+ /**
9
+ *
10
+ * dotob <pattern> -f require -t dependencies.npm
11
+ *
12
+ */
13
+ var dotob = require('../index.js')();
14
+ var program = require('commander');
15
+ var pkg = require('../package.json');
16
+
17
+ program
18
+ .version(pkg.version)
19
+ .usage('[options]')
20
+ .option('-p, --pattern [pattern]', 'Pattern to match')
21
+ .option('-f, --from [path]', 'From path')
22
+ .option('-t, --to [path]', 'To path')
23
+ .option('-m, --merge', 'Merge into target')
24
+ .option('-v, --verbose', 'Be verbose')
25
+ .option('-d, --dry', 'Dry run do not modify files')
26
+ .parse(process.argv);
27
+
28
+ function must(program, option) {
29
+ if(!program.hasOwnProperty(option)) {
30
+ console.log([
31
+ 'The', option, 'is required'
32
+ ].join(' '));
33
+ process.exit(1);
34
+ }
35
+ }
36
+
37
+ must(program, 'pattern');
38
+ must(program, 'from');
39
+ must(program, 'to');
40
+
41
+ var g = glob(program.pattern);
42
+
43
+ function finish(program, file, orig, json) {
44
+
45
+ return function(err) {
46
+ if (err) {
47
+ throw err;
48
+ } else {
49
+ if (program.verbose) {
50
+ if (JSON.stringify(orig) !== JSON.stringify(json)) {
51
+ console.log(file + ': updated.');
52
+ } else {
53
+ console.log(file + ': no matches.');
54
+ }
55
+ }
56
+ }
57
+ };
58
+ }
59
+
60
+ function processFile(file) {
61
+
62
+ fs.readFile(file, 'utf8', function(err, contents) {
63
+ var json, orig;
64
+ try {
65
+ orig = JSON.parse(contents);
66
+ json = JSON.parse(contents);
67
+ dotob.move(program.from, program.to, json, program.merge);
68
+ if(program.dry) {
69
+ console.log(json);
70
+ finish(program, file, orig, json)();
71
+ } else {
72
+ fs.writeFile(file, JSON.stringify(json, null, 2), finish(
73
+ program, file, orig, json
74
+ ));
75
+ }
76
+ } catch (e) {
77
+ console.log(file + ': ', e);
78
+ }
79
+ });
80
+ }
81
+
82
+ g.on('match', function(file) {
83
+ processFile(file);
84
+ });
package/index.js CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  function DotObject(seperator, override) {
4
4
 
5
- if(!(this instanceof DotObject)) return new DotObject(seperator, override);
5
+ if (!(this instanceof DotObject)) {
6
+ return new DotObject(seperator, override);
7
+ }
6
8
 
7
9
  if (typeof seperator === 'undefined') { seperator = '.'; }
8
10
  if (typeof override === 'undefined') { override = false; }
@@ -10,7 +12,7 @@ function DotObject(seperator, override) {
10
12
  this.override = override;
11
13
  }
12
14
 
13
- DotObject.prototype._fill = function (a, obj, v, mod) {
15
+ DotObject.prototype._fill = function(a, obj, v, mod) {
14
16
  var k = a.shift();
15
17
 
16
18
  if (a.length > 0) {
@@ -20,7 +22,9 @@ DotObject.prototype._fill = function (a, obj, v, mod) {
20
22
  if (this.override) {
21
23
  obj[k] = {};
22
24
  } else {
23
- throw new Error('Trying to redefine \'' + k + '\' which is a ' + typeof obj[k]);
25
+ throw new Error(
26
+ 'Trying to redefine `' + k + '` which is a ' + typeof obj[k]
27
+ );
24
28
  }
25
29
  }
26
30
 
@@ -34,7 +38,7 @@ DotObject.prototype._fill = function (a, obj, v, mod) {
34
38
  }
35
39
  };
36
40
 
37
- DotObject.prototype.process = function (v, mod) {
41
+ DotObject.prototype.process = function(v, mod) {
38
42
  var i;
39
43
 
40
44
  if (typeof mod === 'function') {
@@ -48,10 +52,10 @@ DotObject.prototype.process = function (v, mod) {
48
52
  return v;
49
53
  };
50
54
 
51
- DotObject.prototype.object = function (obj, mods) {
55
+ DotObject.prototype.object = function(obj, mods) {
52
56
  var self = this;
53
57
 
54
- Object.keys(obj).forEach(function (k, i) {
58
+ Object.keys(obj).forEach(function(k) {
55
59
  var mod = mods === undefined ? null : mods[k];
56
60
 
57
61
  if (k.indexOf(self.seperator) !== -1) {
@@ -63,7 +67,15 @@ DotObject.prototype.object = function (obj, mods) {
63
67
  });
64
68
  };
65
69
 
66
- DotObject.prototype.str = function (str, v, obj, mod) {
70
+ /**
71
+ *
72
+ * @param {String} str
73
+ * @param {String} v
74
+ * @param {Object} obj
75
+ * @param {Function|Array} mod
76
+ *
77
+ */
78
+ DotObject.prototype.str = function(str, v, obj, mod) {
67
79
  if (str.indexOf(this.seperator) !== -1) {
68
80
  this._fill(str.split(this.seperator), obj, v, mod);
69
81
  } else if (this.override) {
@@ -81,15 +93,17 @@ DotObject.prototype.str = function (str, v, obj, mod) {
81
93
  * @param {Object} obj
82
94
  * @param {Boolean} remove
83
95
  */
84
- DotObject.prototype.pick = function (path, obj, remove) {
85
- var i, keys, val;
96
+ DotObject.prototype.pick = function(path, obj, remove) {
97
+ var i;
98
+ var keys;
99
+ var val;
86
100
 
87
101
  if (path.indexOf(this.seperator) !== -1) {
88
102
  keys = path.split(this.seperator);
89
103
  for (i = 0; i < keys.length; i++) {
90
- if(obj.hasOwnProperty(keys[i])) {
91
- if(i === (keys.length - 1)) {
92
- if(remove) {
104
+ if (obj.hasOwnProperty(keys[i])) {
105
+ if (i === (keys.length - 1)) {
106
+ if (remove) {
93
107
  val = obj[keys[i]];
94
108
  delete obj[keys[i]];
95
109
  return val;
@@ -105,7 +119,7 @@ DotObject.prototype.pick = function (path, obj, remove) {
105
119
  }
106
120
  return obj;
107
121
  } else {
108
- if(remove) {
122
+ if (remove) {
109
123
  val = obj[path];
110
124
  delete obj[path];
111
125
  return val;
@@ -125,11 +139,12 @@ DotObject.prototype.pick = function (path, obj, remove) {
125
139
  * @param {String} source
126
140
  * @param {String} target
127
141
  * @param {Object} obj
142
+ * @param {Boolean} merge
128
143
  *
129
144
  */
130
- DotObject.prototype.move = function (source, target, obj) {
145
+ DotObject.prototype.move = function(source, target, obj, merge) {
131
146
 
132
- this.set(target, this.pick(source, obj, true), obj);
147
+ this.set(target, this.pick(source, obj, true), obj, merge);
133
148
 
134
149
  return obj;
135
150
 
@@ -144,44 +159,101 @@ DotObject.prototype.move = function (source, target, obj) {
144
159
  *
145
160
  * @param {String} source
146
161
  * @param {String} target
147
- * @param {Object} obj
162
+ * @param {Object} obj1
163
+ * @param {Object} obj2
164
+ * @param {Boolean} merge
165
+ */
166
+ DotObject.prototype.transfer = function(source, target, obj1, obj2, merge) {
167
+
168
+ this.set(target, this.pick(source, obj1, true), obj2, merge);
169
+
170
+ return obj2;
171
+
172
+ };
173
+
174
+ /**
175
+ *
176
+ * Copy a property from one object to another object.
177
+ *
178
+ * If the source path does not exist (undefined)
179
+ * the property on the other object will not be set.
148
180
  *
181
+ * @param {String} source
182
+ * @param {String} target
183
+ * @param {Object} obj1
184
+ * @param {Object} obj2
185
+ * @param {Boolean} merge
149
186
  */
150
- DotObject.prototype.transfer = function (source, target, obj1, obj2) {
187
+ DotObject.prototype.copy = function(source, target, obj1, obj2, merge) {
151
188
 
152
- this.set(target, this.pick(source, obj1, true), obj2);
189
+ this.set(target, this.pick(source, obj1, false), obj2, merge);
153
190
 
154
191
  return obj2;
155
192
 
156
193
  };
157
194
 
195
+ function isObject(val) {
196
+ return Object.prototype.toString.call(val) === '[object Object]';
197
+ }
198
+
158
199
  /**
159
200
  *
160
201
  * Set a property on an object using dot notation.
161
202
  *
203
+ * @param {String} path
204
+ * @param {Mixed} val
205
+ * @param {Object} obj
206
+ * @param {Boolean} merge
162
207
  */
163
- DotObject.prototype.set = function (path, val, obj) {
164
- var i, keys;
208
+ DotObject.prototype.set = function(path, val, obj, merge) {
209
+ var i;
210
+ var k;
211
+ var keys;
165
212
 
166
213
  // Do not operate if the value is undefined.
167
- if(typeof val === 'undefined') return obj;
214
+ if (typeof val === 'undefined') {
215
+ return obj;
216
+ }
168
217
 
169
218
  if (path.indexOf(this.seperator) !== -1) {
170
219
  keys = path.split(this.seperator);
171
220
  for (i = 0; i < keys.length; i++) {
172
- if(i === (keys.length - 1)) {
173
- obj[keys[i]] = val;
174
- } else if(
221
+ if (i === (keys.length - 1)) {
222
+ if (merge && isObject(val) && isObject(obj[keys[i]])) {
223
+ for (k in val) {
224
+ if (val.hasOwnProperty(k)) {
225
+ obj[keys[i]][k] = val[k];
226
+ }
227
+ }
228
+
229
+ } else if (Array.isArray(obj[keys[i]]) && Array.isArray(val)) {
230
+ for (var j = 0; j < val.length; j++) {
231
+ obj[keys[i]].push(val[j]);
232
+ }
233
+ } else {
234
+ obj[keys[i]] = val;
235
+ }
236
+ } else if (
175
237
  // force the value to be an object
176
238
  !obj.hasOwnProperty(keys[i]) ||
177
- Object.prototype.toString.call(obj[keys[i]]) !== '[object Object]') {
239
+ !isObject(obj[keys[i]])) {
178
240
  obj[keys[i]] = {};
179
241
  }
180
242
  obj = obj[keys[i]];
181
243
  }
182
244
  return obj;
183
245
  } else {
184
- obj[path] = val;
246
+ if (merge && isObject(val)) {
247
+ for (k in val) {
248
+ if (val.hasOwnProperty(k)) {
249
+ obj[path][k] = val[k];
250
+ }
251
+ }
252
+ } else if (Array.isArray(obj[path]) && Array.isArray(val)) {
253
+ obj[path].push(val);
254
+ } else {
255
+ obj[path] = val;
256
+ }
185
257
  return obj;
186
258
  }
187
259
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dot-object",
3
3
  "description": "dot-object makes it possible to transform and read (JSON) objects using dot notation.",
4
- "version": "0.3.0",
4
+ "version": "0.6.0",
5
5
  "author": {
6
6
  "name": "Rob Halff",
7
7
  "email": "rob.halff@gmail.com"
@@ -15,16 +15,18 @@
15
15
  },
16
16
  "main": "index",
17
17
  "scripts": {
18
- "test": "mocha"
18
+ "test": "gulp test"
19
19
  },
20
20
  "devDependencies": {
21
21
  "underscore.string": "latest",
22
22
  "mocha": "1.x.x",
23
23
  "should": "1.x.x",
24
- "grunt": "0.x.x",
25
- "grunt-release": "0.x.x",
26
- "grunt-contrib-watch": "0.x.x",
27
- "grunt-shell": "0.x.x"
24
+ "gulp-jshint": "^1.9.0",
25
+ "gulp-mocha": "^1.1.1",
26
+ "gulp": "^3.8.10",
27
+ "gulp-jscs": "^1.3.0",
28
+ "jscs": "^1.7.3",
29
+ "jscs-jsdoc": "0.0.23"
28
30
  },
29
31
  "keywords": [
30
32
  "json",
@@ -32,5 +34,8 @@
32
34
  "transform",
33
35
  "dot notation",
34
36
  "dot"
35
- ]
37
+ ],
38
+ "dependencies": {
39
+ "commander": "^2.5.0"
40
+ }
36
41
  }
package/test/dot-json.js CHANGED
@@ -1,10 +1,12 @@
1
+ 'use strict';
2
+
1
3
  require('should');
2
4
  var _s = require('underscore.string');
3
5
  var DJ = require('../index.js');
4
6
 
5
- describe("Dot Object test:", function () {
7
+ describe('Dot Object test:', function() {
6
8
 
7
- it("Should Dot object keys", function (done) {
9
+ it('Should Dot object keys', function() {
8
10
 
9
11
  var dj = new DJ();
10
12
 
@@ -19,26 +21,24 @@ describe("Dot Object test:", function () {
19
21
  dj.object(row);
20
22
 
21
23
  row.should.eql({
22
- "id": 2,
23
- "contact": {
24
- "name": {
25
- "first": "John",
26
- "last": "Doe"
24
+ 'id': 2,
25
+ 'contact': {
26
+ 'name': {
27
+ 'first': 'John',
28
+ 'last': 'Doe'
27
29
  },
28
- "email": "example@gmail.com",
29
- "info": {
30
- "about": {
31
- "me": "classified"
30
+ 'email': 'example@gmail.com',
31
+ 'info': {
32
+ 'about': {
33
+ 'me': 'classified'
32
34
  }
33
35
  }
34
36
  }
35
37
  });
36
38
 
37
- done();
38
-
39
39
  });
40
40
 
41
- it("Should Dot Object a string", function (done) {
41
+ it('Should Dot Object a string', function() {
42
42
 
43
43
  var obj = {};
44
44
 
@@ -47,38 +47,34 @@ describe("Dot Object test:", function () {
47
47
  dj.str('this.is.my.string', 'value', obj);
48
48
 
49
49
  obj.should.eql({
50
- "this": {
51
- "is": {
52
- "my": {
53
- "string": "value"
50
+ 'this': {
51
+ 'is': {
52
+ 'my': {
53
+ 'string': 'value'
54
54
  }
55
55
  }
56
56
  }
57
57
  });
58
58
 
59
- done();
60
-
61
59
  });
62
60
 
63
- it("DJ.str Redefinition should fail", function (done) {
61
+ it('DJ.str Redefinition should fail', function() {
64
62
 
65
63
  var obj = {
66
64
  'already': 'set'
67
65
  };
68
66
 
69
- (function () {
67
+ (function() {
70
68
 
71
69
  var dj = new DJ();
72
70
 
73
71
  dj.str('already.new', 'value', obj);
74
72
 
75
- }).should.throw("Trying to redefine 'already' which is a string");
76
-
77
- done();
73
+ }).should.throw('Trying to redefine `already` which is a string');
78
74
 
79
75
  });
80
76
 
81
- it("DJ.str should process a modifier", function (done) {
77
+ it('DJ.str should process a modifier', function() {
82
78
 
83
79
  var obj = {};
84
80
 
@@ -87,42 +83,42 @@ describe("Dot Object test:", function () {
87
83
  dj.str('this.is.my.string', 'value', obj, _s.capitalize);
88
84
 
89
85
  obj.should.eql({
90
- "this": {
91
- "is": {
92
- "my": {
93
- "string": "Value"
86
+ 'this': {
87
+ 'is': {
88
+ 'my': {
89
+ 'string': 'Value'
94
90
  }
95
91
  }
96
92
  }
97
93
  });
98
94
 
99
- done();
100
-
101
95
  });
102
96
 
103
- it("DOT.str should process multiple modifiers", function (done) {
97
+ it('DOT.str should process multiple modifiers', function() {
104
98
 
105
99
  var obj = {};
106
100
 
107
101
  var dj = new DJ();
108
102
 
109
- dj.str('this.is.my.string', ' this is a test ', obj, [_s.trim, _s.underscored]);
103
+ dj.str(
104
+ 'this.is.my.string',
105
+ ' this is a test ',
106
+ obj, [_s.trim, _s.underscored]
107
+ );
110
108
 
111
109
  obj.should.eql({
112
- "this": {
113
- "is": {
114
- "my": {
115
- "string": "this_is_a_test"
110
+ 'this': {
111
+ 'is': {
112
+ 'my': {
113
+ 'string': 'this_is_a_test'
116
114
  }
117
115
  }
118
116
  }
119
117
  });
120
118
 
121
- done();
122
-
123
119
  });
124
120
 
125
- it("DJ.object should process a modifier", function (done) {
121
+ it('DJ.object should process a modifier', function() {
126
122
 
127
123
  var row = {
128
124
  'page.title': 'my page',
@@ -130,92 +126,56 @@ describe("Dot Object test:", function () {
130
126
  };
131
127
 
132
128
  var mods = {
133
- "page.title": _s.titleize,
134
- "page.slug": _s.slugify
129
+ 'page.title': _s.titleize,
130
+ 'page.slug': _s.slugify
135
131
  };
136
132
 
137
133
  var dj = new DJ();
138
134
 
139
135
  dj.object(row, mods);
140
136
 
141
- row.should.eql({
142
- "page": {
143
- "title": "My Page",
144
- "slug": "my-page"
145
- }
146
- });
147
-
148
- done();
137
+ row.should.eql({'page': {'title': 'My Page', 'slug': 'my-page'}});
149
138
 
150
139
  });
151
140
 
152
- it("DJ.object should not process non dot notation value with modifier when DJ.override is false", function (done) {
141
+ it('should not process non dot value with modifier when override is false',
142
+ function() {
153
143
 
154
- var row = {
155
- 'title': 'my page',
156
- 'slug': 'My Page'
157
- };
144
+ var row = {'title': 'my page', 'slug': 'My Page'};
158
145
 
159
- var mods = {
160
- "title": _s.titleize,
161
- "slug": _s.slugify
162
- };
146
+ var mods = {'title': _s.titleize, 'slug': _s.slugify};
163
147
 
164
- var dj = new DJ();
165
- dj.object(row, mods);
166
-
167
- row.should.eql({
168
- "title": "my page",
169
- "slug": "My Page"
170
- });
148
+ var dj = new DJ();
149
+ dj.object(row, mods);
171
150
 
172
- done();
151
+ row.should.eql({'title': 'my page', 'slug': 'My Page'});
173
152
 
174
- });
153
+ }
154
+ );
175
155
 
176
- it("DJ.object should process multiple modifiers", function (done) {
156
+ it('DJ.object should process multiple modifiers', function() {
177
157
 
178
- var row = {
179
- 'page.name': ' My Page '
180
- };
158
+ var row = {'page.name': ' My Page '};
181
159
 
182
- var mods = {
183
- "page.name": [_s.trim, _s.underscored]
184
- };
160
+ var mods = {'page.name': [_s.trim, _s.underscored]};
185
161
 
186
162
  var dj = new DJ();
187
163
  dj.object(row, mods);
188
164
 
189
- row.should.eql({
190
- "page": {
191
- "name": "my_page"
192
- }
193
- });
194
-
195
- done();
165
+ row.should.eql({'page': {'name': 'my_page'}});
196
166
 
197
167
  });
198
168
 
199
- it("DJ.object should work with a different seperator", function (done) {
169
+ it('DJ.object should work with a different seperator', function() {
200
170
 
201
- var row = {
202
- 'page=>name': ' My Page '
203
- };
171
+ var row = {'page=>name': ' My Page '};
204
172
 
205
- var mods = {
206
- "page=>name": [_s.trim, _s.underscored]
207
- };
173
+ var mods = {'page=>name': [_s.trim, _s.underscored]};
208
174
 
209
- var dj = new DJ("=>", false);
175
+ var dj = new DJ('=>', false);
210
176
  dj.object(row, mods);
211
177
 
212
- row.should.eql({
213
- "page": {
214
- "name": "my_page"
215
- }
216
- });
217
-
218
- done();
178
+ row.should.eql({'page': {'name': 'my_page'}});
219
179
 
220
180
  });
221
181
 
package/test/merge.js ADDED
@@ -0,0 +1,104 @@
1
+ 'use strict';
2
+
3
+ require('should');
4
+ var dj = require('../index.js')();
5
+
6
+ describe('Should be able to merge:', function() {
7
+
8
+ it('to property', function() {
9
+
10
+ var link = {
11
+ other: {
12
+ three: 'Three Things',
13
+ four: 'Four Things'
14
+ },
15
+ things: {
16
+ one: 'One Thing',
17
+ two: 'Two Things'
18
+ }
19
+ };
20
+
21
+ var expected = {
22
+ things: {
23
+ one: 'One Thing',
24
+ two: 'Two Things',
25
+ three: 'Three Things',
26
+ four: 'Four Things'
27
+ }
28
+ };
29
+
30
+ dj.move('other', 'things', link, true);
31
+
32
+ link.should.eql(expected);
33
+
34
+ });
35
+
36
+ it('to nested property', function() {
37
+
38
+ var link = {
39
+ other: {
40
+ three: 'Three Things',
41
+ four: 'Four Things'
42
+ },
43
+ things: {
44
+ one: 'One Thing',
45
+ two: 'Two Things',
46
+ target: {
47
+ im: 'already here'
48
+ }
49
+ }
50
+ };
51
+
52
+ var expected = {
53
+ things: {
54
+ one: 'One Thing',
55
+ two: 'Two Things',
56
+ target: {
57
+ im: 'already here',
58
+ three: 'Three Things',
59
+ four: 'Four Things'
60
+ }
61
+ }
62
+ };
63
+
64
+ dj.move('other', 'things.target', link, true);
65
+
66
+ link.should.eql(expected);
67
+
68
+ });
69
+
70
+ it('array to array', function() {
71
+
72
+ var link = {
73
+ other: [
74
+ 'Three Things',
75
+ 'Four Things'
76
+ ],
77
+ things: {
78
+ one: 'One Thing',
79
+ two: 'Two Things',
80
+ target: [
81
+ 'already here'
82
+ ]
83
+ }
84
+ };
85
+
86
+ var expected = {
87
+ things: {
88
+ one: 'One Thing',
89
+ two: 'Two Things',
90
+ target: [
91
+ 'already here',
92
+ 'Three Things',
93
+ 'Four Things'
94
+ ]
95
+ }
96
+ };
97
+
98
+ dj.move('other', 'things.target', link, true);
99
+
100
+ link.should.eql(expected);
101
+
102
+ });
103
+
104
+ });
package/test/move.js CHANGED
@@ -1,10 +1,11 @@
1
+ 'use strict';
2
+
1
3
  require('should');
2
- var _s = require('underscore.string');
3
4
  var dj = require('../index.js')();
4
5
 
5
- describe("DJ value picker:", function () {
6
+ describe('DJ value picker:', function() {
6
7
 
7
- it("Should be able to move properties", function (done) {
8
+ it('Should be able to move properties', function() {
8
9
 
9
10
  var link = {
10
11
  id: '527423a65e380f0000588e47',
@@ -16,8 +17,8 @@ describe("DJ value picker:", function () {
16
17
 
17
18
  var expected = {
18
19
  id: '527423a65e380f0000588e47',
19
- source: { id: '526dd5c6b4c4aa8770000001', port: 'github' },
20
- target: { id: '527402d6b15d1800008755cf', port: 'in' }
20
+ source: {id: '526dd5c6b4c4aa8770000001', port: 'github'},
21
+ target: {id: '527402d6b15d1800008755cf', port: 'in'}
21
22
  };
22
23
 
23
24
  dj.move('source', 'source.id', link);
@@ -27,11 +28,9 @@ describe("DJ value picker:", function () {
27
28
 
28
29
  link.should.eql(expected);
29
30
 
30
- done();
31
-
32
31
  });
33
32
 
34
- it("Undefined properties should be ignored", function (done) {
33
+ it('Undefined properties should be ignored', function() {
35
34
 
36
35
  var link = {
37
36
  source: '526dd5c6b4c4aa8770000001',
@@ -41,8 +40,8 @@ describe("DJ value picker:", function () {
41
40
  };
42
41
 
43
42
  var expected = {
44
- source: { id: '526dd5c6b4c4aa8770000001' },
45
- target: { port: 'in' },
43
+ source: {id: '526dd5c6b4c4aa8770000001'},
44
+ target: {port: 'in'},
46
45
  out: 'github'
47
46
  };
48
47
 
@@ -53,8 +52,6 @@ describe("DJ value picker:", function () {
53
52
 
54
53
  link.should.eql(expected);
55
54
 
56
- done();
57
-
58
55
  });
59
56
 
60
57
  });
package/test/override.js CHANGED
@@ -1,11 +1,12 @@
1
+ 'use strict';
2
+
1
3
  require('should');
2
4
  var _s = require('underscore.string');
3
5
  var DJ = require('../index.js');
4
6
 
5
- describe("DJ test:", function () {
6
-
7
+ describe('DJ test:', function() {
7
8
 
8
- it("Redefinition should _not_ fail if override is true", function (done) {
9
+ it('Redefinition should _not_ fail if override is true', function() {
9
10
 
10
11
  var dj = new DJ('.', true);
11
12
 
@@ -17,15 +18,13 @@ describe("DJ test:", function () {
17
18
  dj.str('already.new', 'value', obj);
18
19
 
19
20
  obj.should.eql({
20
- "some": "value",
21
- "already": { "new": "value" }
21
+ 'some': 'value',
22
+ 'already': {'new': 'value'}
22
23
  });
23
24
 
24
- done();
25
-
26
25
  });
27
26
 
28
- it("Redefinition should _not_ fail if override is true", function (done) {
27
+ it('Redefinition should _not_ fail if override is true', function() {
29
28
 
30
29
  var dj = new DJ('.', true);
31
30
 
@@ -38,37 +37,35 @@ describe("DJ test:", function () {
38
37
  dj.str('some', 'new_value', obj);
39
38
 
40
39
  obj.should.eql({
41
- "some": "new_value",
42
- "already": { "new": "value" }
40
+ 'some': 'new_value',
41
+ 'already': {'new': 'value'}
43
42
  });
44
43
 
45
- done();
46
-
47
44
  });
48
45
 
49
- it("DJ.object _should_ process non dot notation value with modifier when DJ.override is true", function (done) {
46
+ it('should process non dot notation value with modifier if override is true',
47
+ function() {
50
48
 
51
- var dj = new DJ('.', true);
49
+ var dj = new DJ('.', true);
52
50
 
53
- var row = {
54
- 'title': 'my page',
55
- 'slug': 'My Page'
56
- };
51
+ var row = {
52
+ 'title': 'my page',
53
+ 'slug': 'My Page'
54
+ };
57
55
 
58
- var mods = {
59
- "title": _s.titleize,
60
- "slug": _s.slugify
61
- };
56
+ var mods = {
57
+ 'title': _s.titleize,
58
+ 'slug': _s.slugify
59
+ };
62
60
 
63
- dj.object(row, mods);
61
+ dj.object(row, mods);
64
62
 
65
- row.should.eql({
66
- "title": "My Page",
67
- "slug": "my-page"
68
- });
63
+ row.should.eql({
64
+ 'title': 'My Page',
65
+ 'slug': 'my-page'
66
+ });
69
67
 
70
- done();
71
-
72
- });
68
+ }
69
+ );
73
70
 
74
71
  });
package/test/pick.js CHANGED
@@ -1,10 +1,11 @@
1
+ 'use strict';
2
+
1
3
  require('should');
2
- var _s = require('underscore.string');
3
4
  var DJ = require('../index.js');
4
5
 
5
- describe("DJ value picker:", function () {
6
+ describe('DJ value picker:', function() {
6
7
 
7
- it("Should be able to pick a value", function (done) {
8
+ it('Should be able to pick a value', function() {
8
9
 
9
10
  var dj = new DJ('.', true);
10
11
 
@@ -17,11 +18,9 @@ describe("DJ value picker:", function () {
17
18
 
18
19
  val.should.eql('value');
19
20
 
20
- done();
21
-
22
21
  });
23
22
 
24
- it("Should be able to pick dotted value", function (done) {
23
+ it('Should be able to pick dotted value', function() {
25
24
 
26
25
  var dj = new DJ();
27
26
 
@@ -35,8 +34,6 @@ describe("DJ value picker:", function () {
35
34
 
36
35
  val.should.eql('value');
37
36
 
38
- done();
39
-
40
37
  });
41
38
 
42
39
  });
File without changes