/*global window, global*/ var util = require("util") var assert = require("assert") var now = require("date-now") var slice = Array.prototype.slice var console var times = {} if (typeof global !== "undefined" && global.console) { console = global.console } else if (typeof window !== "undefined" && window.console) { console = window.console } else { console = {} } var functions = [ [log, "log"], [info, "info"], [warn, "warn"], [error, "error"], [time, "time"], [timeEnd, "timeEnd"], [trace, "trace"], [dir, "dir"], [consoleAssert, "assert"] ] for (var i = 0; i < functions.length; i++) { var tuple = functions[i] var f = tuple[0] var name = tuple[1] if (!console[name]) { console[name] = f } } module.exports = console function log() {} function info() { console.log.apply(console, arguments) } function warn() { console.log.apply(console, arguments) } function error() { console.warn.apply(console, arguments) } function time(label) { times[label] = now() } function timeEnd(label) { var time = times[label] if (!time) { throw new Error("No such label: " + label) } var duration = now() - time console.log(label + ": " + duration + "ms") } function trace() { var err = new Error() err.name = "Trace" err.message = util.format.apply(null, arguments) console.error(err.stack) } function dir(object) { console.log(util.inspect(object) + "\n") } function consoleAssert(expression) { if (!expression) { var arr = slice.call(arguments, 1) assert.ok(false, util.format.apply(null, arr)) } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 19553 | swellard | Move and rename clients | ||
//guest/perforce_software/helix-web-services/main/source/clients/2016.1.0/javascript/node_modules/console-browserify/index.js | |||||
#1 | 18810 | tjuricek |
First-pass at JavaScript client SDK. JavaScript requires Node with Gulp to "browserfy" the library. It's the easiest way I found to use the swagger-js project; bundle up a wrapping method. There is no JavaScript reference guide. The swagger-js doesn't really document what they do very well, actually. Overall I'm not particularly impressed by swagger-js, it was hard to even figure out what the right method syntax was. We may want to invest time in doing it better. This required setting CORS response headers, which are currently defaulted to a fairly insecure setting. |