From 61808e8247e8d083e44a1c2b30b06f34e959a0a9 Mon Sep 17 00:00:00 2001 From: Max Filenko Date: Sun, 13 Aug 2017 20:39:26 +0200 Subject: [PATCH 1/2] Use embedded clone capabilities --- lib/figo.js | 23 ++++++++++++++++++++--- package.json | 1 - 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/lib/figo.js b/lib/figo.js index 5d97eb4..7398c84 100644 --- a/lib/figo.js +++ b/lib/figo.js @@ -27,7 +27,6 @@ var querystring = require("querystring"); var crypto = require("crypto"); // External dependencies. -var clone = require("clone"); var winston = require("winston"); // Internal modules. @@ -785,7 +784,16 @@ var Session = function(access_token) { // The result parameter is an array of `Security` objects. // this.get_securities = function(options, callback) { - options = options == null ? {} : clone(options); + if (typeof options === "object" && options !== null) { + try { + options = JSON.parse(JSON.stringify(options)); + } catch (e) { + winston.log('warn', 'corrupted `options` object'); + options = {}; + } + } else { + options = {}; + } if (typeof options.since !== "undefined") options.since = typeof options.since === "object" ? options.since.toISOString() : options.since; options.count = typeof options.count === "undefined" ? 1000 : options.count; @@ -847,7 +855,16 @@ var Session = function(access_token) { // The result parameter is an array of `Transaction` objects, one for each transaction of the user. // this.get_transactions = function(options, callback) { - options = options == null ? {} : clone(options); + if (typeof options === "object" && options !== null) { + try { + options = JSON.parse(JSON.stringify(options)); + } catch (e) { + winston.log('warn', 'corrupted `options` object'); + options = {}; + } + } else { + options = {}; + } if (typeof options.since !== "undefined") options.since = typeof options.since === "object" ? options.since.toISOString() : options.since; options.count = typeof options.count === "undefined" ? 1000 : options.count; diff --git a/package.json b/package.json index 2b6532f..23d57c0 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,6 @@ "node": ">=0.11.0" }, "dependencies": { - "clone": "^1.0.2", "winston": "^2.3.0" } } From a9222b1f28a49c1e1ff203e4e470cedd5ec7a9cf Mon Sep 17 00:00:00 2001 From: Max Filenko Date: Sun, 13 Aug 2017 20:46:56 +0200 Subject: [PATCH 2/2] Date has been already stringified while cloning --- lib/figo.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/figo.js b/lib/figo.js index 7398c84..852580a 100644 --- a/lib/figo.js +++ b/lib/figo.js @@ -794,8 +794,6 @@ var Session = function(access_token) { } else { options = {}; } - if (typeof options.since !== "undefined") - options.since = typeof options.since === "object" ? options.since.toISOString() : options.since; options.count = typeof options.count === "undefined" ? 1000 : options.count; options.offset = typeof options.offset === "undefined" ? 0 : options.offset; if (typeof options.account_id === "undefined") { @@ -865,8 +863,6 @@ var Session = function(access_token) { } else { options = {}; } - if (typeof options.since !== "undefined") - options.since = typeof options.since === "object" ? options.since.toISOString() : options.since; options.count = typeof options.count === "undefined" ? 1000 : options.count; options.offset = typeof options.offset === "undefined" ? 0 : options.offset; options.include_pending = options.include_pending ? 1 : 0;