Blame view
node_modules/strong-globalize/browser.js
4.09 KB
f7563de62
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
// Copyright IBM Corp. 2015,2016. All Rights Reserved. // Node module: strong-globalize // This file is licensed under the Artistic License 2.0. // License text available at https://opensource.org/licenses/Artistic-2.0 'use strict'; var util = require('util'); exports = module.exports = StrongGlobalize; exports.SetRootDir = noop; exports.SetDefaultLanguage = noop; exports.SetPersistentLogging = noop; function StrongGlobalize() { if (!(this instanceof StrongGlobalize)) { return new StrongGlobalize(); } } function noop() {} StrongGlobalize.prototype.setLanguage = noop; StrongGlobalize.prototype.getLanguage = function() { return 'en'; }; StrongGlobalize.prototype.c = function(value, currencySymbol, options) { return currencySymbol + ' ' + value.toString(); }; StrongGlobalize.prototype.formatCurrency = StrongGlobalize.prototype.c; StrongGlobalize.prototype.d = function(value, options) { return value.toSyring(); }; StrongGlobalize.prototype.formatDate = StrongGlobalize.prototype.d; StrongGlobalize.prototype.n = function(value, options) { return value.toString(); }; StrongGlobalize.prototype.formatNumber = StrongGlobalize.prototype.n; StrongGlobalize.prototype.m = function(path, variables) { return util.format.apply(null, [path].concat(variables)); }; StrongGlobalize.prototype.formatMessage = StrongGlobalize.prototype.m; StrongGlobalize.prototype.t = StrongGlobalize.prototype.m; StrongGlobalize.prototype.Error = function() { return Error.apply(null, arguments); }; StrongGlobalize.prototype.f = function() { return util.format.apply(null, arguments); }; StrongGlobalize.prototype.format = StrongGlobalize.prototype.f; StrongGlobalize.prototype.ewrite = function() { return process.stderr.apply(null, arguments); }; StrongGlobalize.prototype.owrite = function() { return process.stdout.apply(null, arguments); }; StrongGlobalize.prototype.write = StrongGlobalize.prototype.owrite; function rfc5424(type, args, fn) { // Convert args from function arguments object to a regular array args = Array.prototype.slice.call(args); if (typeof args[0] === 'string') { // The first argument may contain formatting instructions like %s // which must be preserved. args[0] = type + ': ' + args[0]; } else { args = [type, ': '].concat(args); } return fn.apply(console, args); } // RFC 5424 Syslog Message Severities StrongGlobalize.prototype.emergency = function() { return rfc5424('emergency', arguments, console.error); }; StrongGlobalize.prototype.alert = function() { return rfc5424('alert', arguments, console.error); }; StrongGlobalize.prototype.critical = function() { return rfc5424('critical', arguments, console.error); }; StrongGlobalize.prototype.error = function() { return rfc5424('error', arguments, console.error); }; StrongGlobalize.prototype.warning = function() { return rfc5424('warning', arguments, console.warn); }; StrongGlobalize.prototype.notice = function() { return rfc5424('notice', arguments, console.log); }; StrongGlobalize.prototype.informational = function() { return rfc5424('informational', arguments, console.log); }; StrongGlobalize.prototype.debug = function() { return rfc5424('debug', arguments, console.log); }; // Node.js console StrongGlobalize.prototype.warn = function() { return rfc5424('warn', arguments, console.warn); }; StrongGlobalize.prototype.info = function() { return rfc5424('info', arguments, console.log); }; StrongGlobalize.prototype.log = function() { return rfc5424('log', arguments, console.log); }; // Misc Logging Levels StrongGlobalize.prototype.help = function() { return rfc5424('help', arguments, console.log); }; StrongGlobalize.prototype.data = function() { return rfc5424('data', arguments, console.log); }; StrongGlobalize.prototype.prompt = function() { return rfc5424('prompt', arguments, console.log); }; StrongGlobalize.prototype.verbose = function() { return rfc5424('verbose', arguments, console.log); }; StrongGlobalize.prototype.input = function() { return rfc5424('input', arguments, console.log); }; StrongGlobalize.prototype.silly = function() { return rfc5424('silly', arguments, console.log); }; |