From 61f21ac84867899146c0a56fada6e571651b57a0 Mon Sep 17 00:00:00 2001 From: Vitaly Puzrin Date: Thu, 9 Oct 2014 05:02:13 +0400 Subject: [PATCH] Replaced `assign` helper --- lib/common/utils.js | 25 +++++++++++++++++++++++++ lib/index.js | 4 +--- lib/renderer.js | 2 +- package.json | 3 +-- 4 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 lib/common/utils.js diff --git a/lib/common/utils.js b/lib/common/utils.js new file mode 100644 index 0000000..452812e --- /dev/null +++ b/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; +}; diff --git a/lib/index.js b/lib/index.js index d034e4d..790106c 100644 --- a/lib/index.js +++ b/lib/index.js @@ -3,9 +3,7 @@ 'use strict'; -var assign = require('object-assign'); - - +var assign = require('./common/utils').assign; var Renderer = require('./renderer'); var ParserBlock = require('./parser_block'); var ParserInline = require('./parser_inline'); diff --git a/lib/renderer.js b/lib/renderer.js index c2d7653..403f556 100644 --- a/lib/renderer.js +++ b/lib/renderer.js @@ -1,7 +1,7 @@ 'use strict'; -var assign = require('object-assign'); +var assign = require('./common/utils').assign; var escapeHtml = require('./helpers').escapeHtml; var unescapeMd = require('./helpers').unescapeMd; var replaceEntities = require('./helpers').replaceEntities; diff --git a/package.json b/package.json index 0aaa954..995bca3 100644 --- a/package.json +++ b/package.json @@ -17,8 +17,7 @@ ], "main": "index.js", "dependencies": { - "argparse": "~ 0.1.15", - "object-assign": "^1.0.0" + "argparse": "~ 0.1.15" }, "devDependencies": { "ansi": "^0.3.0",