Browse Source

Replaced `assign` helper

pull/14/head
Vitaly Puzrin 10 years ago
parent
commit
61f21ac848
  1. 25
      lib/common/utils.js
  2. 4
      lib/index.js
  3. 2
      lib/renderer.js
  4. 3
      package.json

25
lib/common/utils.js

@ -0,0 +1,25 @@
// Utilities
'use strics';
// Merge objects
//
exports.assign = function (obj /*from1, from2, from3, ...*/) {
var sources = Array.prototype.slice.call(arguments, 1);
while (sources.length) {
var source = sources.shift();
if (!source) { continue; }
if (typeof(source) !== 'object') {
throw new TypeError(source + 'must be non-object');
}
for (var p in source) {
if (source.hasOwnProperty(p)) {
obj[p] = source[p];
}
}
}
return obj;
};

4
lib/index.js

@ -3,9 +3,7 @@
'use strict'; 'use strict';
var assign = require('object-assign'); var assign = require('./common/utils').assign;
var Renderer = require('./renderer'); var Renderer = require('./renderer');
var ParserBlock = require('./parser_block'); var ParserBlock = require('./parser_block');
var ParserInline = require('./parser_inline'); var ParserInline = require('./parser_inline');

2
lib/renderer.js

@ -1,7 +1,7 @@
'use strict'; 'use strict';
var assign = require('object-assign'); var assign = require('./common/utils').assign;
var escapeHtml = require('./helpers').escapeHtml; var escapeHtml = require('./helpers').escapeHtml;
var unescapeMd = require('./helpers').unescapeMd; var unescapeMd = require('./helpers').unescapeMd;
var replaceEntities = require('./helpers').replaceEntities; var replaceEntities = require('./helpers').replaceEntities;

3
package.json

@ -17,8 +17,7 @@
], ],
"main": "index.js", "main": "index.js",
"dependencies": { "dependencies": {
"argparse": "~ 0.1.15", "argparse": "~ 0.1.15"
"object-assign": "^1.0.0"
}, },
"devDependencies": { "devDependencies": {
"ansi": "^0.3.0", "ansi": "^0.3.0",

Loading…
Cancel
Save