UNPKG

gpii-universal

Version:

Cross platform, core components of the GPII personalization infrastructure.

39 lines (30 loc) 1.34 kB
/*! GPII Database Utilities Copyright 2017 OCAD university Licensed under the New BSD license. You may not use this file except in compliance with this License. You may obtain a copy of the License at https://github.com/GPII/universal/blob/master/LICENSE.txt */ "use strict"; var fluid = fluid || require("infusion"), gpii = fluid.registerNamespace("gpii"); fluid.registerNamespace("gpii.dbOperation"); /** Use `fluid.stringTemplate` method to replace terms within error.message with actual values. * @param {Object} error - An object that contains an element keyed by "message". * @param {Object} termMap - An object that contains the mapping between terms used within error.message and their actual values. * @return {Object} The input object "error" with terms in error.message being replaced by actual values. */ gpii.dbOperation.composeError = function (error, termMap) { var err = fluid.copy(error); err.message = fluid.stringTemplate(err.message, termMap); return err; }; /** * Returns the current time in a human readable string that also naturally sort in chronological order. * See http://www.ecma-international.org/ecma-262/5.1/#sec-15.9.5.43 * @return {String} The current time in ISO string format. */ gpii.dbOperation.getCurrentTimestamp = function () { return new Date().toISOString(); };