{"_id":"@allbin/output-helpers","_rev":"9-b8157294bdb32bfe9cef3d2ee4ddd540","name":"@allbin/output-helpers","dist-tags":{"latest":"2.2.6"},"versions":{"2.2.6":{"name":"@allbin/output-helpers","version":"2.2.6","author":"","license":"ISC","_id":"@allbin/output-helpers@2.2.6","maintainers":[{"name":"alendri","email":"joakim.johansson@allbinary.se"},{"name":"pscz","email":"samuel.psc.olsson@gmail.com"}],"dist":{"shasum":"9ba4d70b2cd9074b36545fa119ed3496aebb926e","tarball":"https://registry.npmjs.org/@allbin/output-helpers/-/output-helpers-2.2.6.tgz","fileCount":19,"integrity":"sha512-hamUnWkn//5qSSRjC30m58vhVkTByriie9CGSn9l9cB7GLsCsOlHXci1i6arQSSDIkJEBHpmWjpB235Vn4Jh2A==","signatures":[{"sig":"MEUCIQCu9l1HxPrHYfpjdEUXLHSBwhzg0nHtrjnTlxGjsgetbAIgZ1TMYjoVuevWKifhz6WQwtegVncru/VSCCARFbllUNY=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":131209,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh11a8CRA9TVsSAnZWagAAvroP/1v6IgI3zWD75M8CNBHm\nZpmmeE6fGVCKKL6d5126d/wobVkZjh4vvHV6saTa2eq7Z0BGz0yQp5Sdgf2i\nlhJEhsC+8XO/ySeJ+5QpNxlPgAOxoD5CYsKg4ZiOZ4cv5/+jYeC4O62h+EOM\nBGpX/mhwgeujEYOB0yTVc+1yWTfUa2TTl/FZTYdsKtaG66dN3t1o4c9WhCEm\nV4PgodPmPSYsWuGCeaoYfUw6SAHl8eSGhMYxZ7Qhy0UsU8rBqcFBkR2mxPHQ\nfun0UOVq5WUc2HmFCq62pkrXxW7tt//n6cacX7bPmXxbqq7ebINMwuxmCt0/\nlh34RcEfnjLC7oaFcHCmMTDcB85n7MCrdHqpkhQOGld9wWoDQ1rBPcDo/5rq\n+1+p0a9mPKD3nXQ4mG7Eg08pHZ7VeJmOQBCIOQqVqA2+yT9Qr46x8XMkJRlB\n3/Oj4AtIY7Jjh7vxlWAS2QYsosBBLMLRAspFvoAaxjHrOvMC9jlk0goRHu9w\nlajPRZE8jieOwWYc9SL2g69vf4Z9nXo5x+ZQju2KFOrKxCJ9z0LGF2vFJmN1\nARR7lnZIfwLYXiYTmgJY9QzhHcAY3o43r5ZAt6L6qvCWArYrXhMDS9OSBoRz\nltAWLTPk+91Et2uz7LWbeEQeEHvbF4lIsrjYJndGvvXD5s6TuvOsSIOMfRLg\nFbga\r\n=QZY8\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/module/index.js","gitHead":"c5b9a115b6e6c03f64b3d749c0886c0420aab8cb","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"gulp4 build","start":"webpack-dev-server --mode development --open --hot --no-inline","release:major":"gulp4 buildAndReleaseMajor","release:minor":"gulp4 buildAndReleaseMinor","release:patch":"gulp4 buildAndReleasePatch"},"_npmUser":{"name":"pscz","email":"samuel.psc.olsson@gmail.com"},"_npmVersion":"6.14.8","description":"## Usage","directories":{},"resolutions":{"@types/react":"16.8.24"},"_nodeVersion":"12.19.0","_hasShrinkwrap":false,"devDependencies":{"gulp4":"4.0.2","react":"16.9.0","moment":"2.22.2","tslint":"5.10.0","webpack":"4.39.1","gulp-bump":"3.1.3","react-dom":"16.9.0","typescript":"3.x","@babel/core":"7.5.5","@types/jest":"24.0.11","@types/node":"14.11.8","webpack-cli":"3.3.6","@types/react":"16.8.24","babel-loader":"8.0.6","vinyl-buffer":"1.0.1","gulp-sourcemaps":"2.6.5","gulp-typescript":"6.0.0-alpha.1","@types/react-dom":"16.8.3","@babel/preset-env":"7.5.5","webpack-dev-server":"3.7.2","@babel/preset-react":"7.0.0","@types/react-router":"4.4.5","html-webpack-plugin":"3.2.0","tslint-eslint-rules":"5.3.1","@types/react-router-dom":"4.3.1","@babel/preset-typescript":"7.3.3","babel-plugin-transform-react-jsx":"6.24.1"},"peerDependencies":{"moment":"2.x"},"_npmOperationalInternal":{"tmp":"tmp/output-helpers_2.2.6_1603714015341_0.622820856639928","host":"s3://npm-registry-packages"}}},"time":{"created":"2020-10-26T12:06:55.139Z","modified":"2026-04-28T15:26:01.891Z","2.2.6":"2020-10-26T12:06:55.488Z"},"license":"ISC","description":"## Usage","maintainers":[{"email":"samuel.psc.olsson@gmail.com","name":"pscz"},{"email":"noah.hakansson@protonmail.com","name":"noahhakansson"},{"email":"mathias.djarv@allbinary.se","name":"mdjarv"},{"email":"james.taylor@mobilix.io","name":"jamestttt"}],"readme":"# output-helpers\n\n## Usage\n\n`import oh from output-helpers`\n\nOptionally use `oh.config(config_object)` to configure default languages and setup translation dictionaries.\n\n# Functions\n\n## oh.addDictionary\n`oh.addDictionary(dictionary): undefined`\n\nAdd additional dictionaries for the *translate* function to use for lookups.\n\n> See [Dictionary definition](#dictionary-definition).\n\n## oh.dateToMoment\n`oh.dateToMoment(date, utc): Moment`\n\nConverts a javascript date to a Moment.\n\n> `date <Date, required>` - The input javascript date to be converted.\n\n> `utc <bool, default true>` - Instruct moment to use utc parsing.\n\n## oh.format\n`oh.format(value, options): string`\n\n> `value <number, required>` - The value to be formatted.\n\n> `options <object, default {}>` - An object with optional parameters:  \n>\n>*round <number, optional>* - Equivalent to power of oh.roundTo.  \n>*ceil <number, optional>* - Equivalent to power of oh.roundUpTo.  \n>*floor <number, optional>* - Equivalent to power of oh.roundDownTo.  \n>*integer_padding <number, optional>* - Minimum number of characters before the decimal point. Padding with zeros.  \n>*decimal_padding <number, optional>* - Minimum number of characters after the decimal point. Padding with zeros.  \n>*padding <number, optional>* - Ensures the total length of the output to be at least padding length.  \n>*trunc <bool, default false>* - Truncates the value, returning the integer part only using Math.trunc().  \n>*grouping <bool, default false>* - Groups digits before decimal point in groups of 3.\n\nEx: *oh.format(1354.342, { round: 1, grouping: true })* > \"1 350\".\n\n## oh.formatDateAsString\n`oh.formatDateAsString(date, output_format, input_format, utc): string`\n\nFormats a given date according to output_format. Formats are specified according to Moment standard.\n\n> `date <Date|string|Moment|number, required>` - The date to be formatted.\n\n> `output_format <string, default YYYY-MM-DD HH:mm>` - The output format.\n\n> `input_format <string, optional>` - If input date is a string optionally a input format can be specified for Moments parser.\n\n> `utc <bool, default false>` - Instruct moment to use utc parsing.\n\n## oh.formatDateAsTimeString\n`oh.formatDateAsTimeString(date, input_format, utc): string`\n\nFormats given date as *HH:mm*. Equivalent to *oh.formatDateAsString(date, \"HH:mm\")*.\n\n> `date <Date|string|Moment|number, required>` - Date to be formatted.\n\n> `input_format <string, optional>` - If input date is a string optionally a input format can be specified for Moments parser.\n\n> `utc <bool, default true>` - Instruct moment to use utc parsing.\n\n## oh.formatSecondsToMS\n`oh.formatSecondsToMS(value, always_include, padding, colon): string`\n\nConverts a value (seconds) to a [m]m[s]s format: 1m2s.\n\n> `value <integer, required>` - Number of seconds to be formatted.\n\n> `always_include <\"none\"|\"minutes\"|\"seconds\"|\"both\", default \"none\">` - Optional specifyer for which parts to always include.  \n> *none* - If not enough for a minute only returns seconds, if an exact minute the seconds will not be included.  \n> *minutes* - If value not above 60 \"0m\" will be prepended to the seconds.  \n> *seconds* - If value is exact minute \"0s\" will be appended after the minute.  \n> *both* - Will always prepend and append \"0m\" and \"0s\" respectively as needed.\n\n> `padding <bool, default false>` - Toggles if values should be padded so 4 becomes 04. Both minutes and seconds will be padded. Defaults to *false*.\n\n> `colon <bool, default false>` - Changes the output format to be \"mm:ss\" instead of \"[m]m[s]s\". Will always include both minutes and seconds, always padding. Defaults to false.\n\n## oh.getCurrentConfig\n`oh.getCurrentConfig(): OutputHelpers config object`\n\n## oh.getDateLocale\n`oh.getDateLocale(language): Moment locale object`\n\nReturns a Moment locale object for the given language. This is used with Moments *moment.defineLocale* function to add locale support for calendars etc.  \n**NOTE:** OH will automatically add all available locales to moment! You only need to use this if you are running a separate moment instance or to change the definition and re-define the locale with moment manually.\n\n> `language <\"sv-SE\"|\"en-US\", defaults to configured language>` - The language for which to return the locale specifications.\n\n## oh.getFallbackLang\n`oh.getFallbackLang(): \"sv-SE\" | \"en-US\"`\n\nReturns the currently configured fallback language used by *oh.translate* when primary language is not found.\n\n## oh.getLang\n`oh.getLang(): \"sv-SE\" | \"en-US\"`\n\nReturns the currently configured language used by *oh.translate*.\n\n## oh.roundDownTo\n`oh.roundDownTo(value, power): number`\n\nReturns value rounded down to the power.\n\n> `value <number, required>` - The value to be rounded.\n\n> `power <number, default 0>` - The power to round to.\n\nEx: *roundDownTo(1345.341, 1)* > 1340\n\n## oh.roundTo\n`oh.roundTo(value, ???): number`\n\nReturns value rounded to the power.\n\n> `value <number, required>` - The value to be rounded.\n\n> `power <number, default 0>` - The power to round to.\n\nEx: *roundTo(1345.341, 1)* > 1350\n\n## oh.roundUpTo\n`oh.roundUpTo(value, ???): number`\n\nReturns value rounded to the power.\n\n> `value <number, required>` - The value to be rounded.\n\n> `power <number, default 0>` - The power to round to.\n\nEx: *roundUpTo(1345.341, 2)* > 1400\n\n## oh.setConfig\n`oh.setConfig(config_options): undefined`\n\nSets the config options. Should be an object with any of the following settings.\n\n`date_locale <\"sv-SE\"|\"en-US\", default same as *lang*>` - Specifies the locale used by Moment.  \n`fallback_language <\"sv-SE\"|\"en-US\", default \"en-US\">` - Fallback used by translate function if *lang* is not available.  \n`lang <\"sv-SE\"|\"en-US\", default \"en-US\">` - Default language used by translate function.  \n`extend_with <object, default null>` - An object to extend the OH object with. Use this to attach additional dynamic functionality to OH.\n\n## oh.translate\n`oh.translate(key, capitalize, language, empty_on_error, dictionary): string`\n\nLooks up key in dictionary for language and returns specified value.  \nWill use the configured language and dictionaries unless specified.\n\n>`key <string, required>` - The key to look for in dictionary.\n\n>`capitalize <bool, default true` - Capitalizes the returned value.\n\n>`language <\"sv-SE\"|\"en-US\", default to configured language>` - Language to check for in dictionary.\n\n>`empty_on_error <true|false, default false>` - When `true` an empty string will be returned when the requested key or language is not found. When `false` the key is returned.  \n>*NOTE: Does not affect error logging.*\n\n>`dictionary <object, default to configured and added dictionaries>` - **See the `oh.addDictionary()` docs.**\n\n## oh.translateTyped\n`oh.translateTyped<T>(key, capitalize, language, empty_on_error, dictionary): string`\n\nEquivalent to `oh.translate` but takes in a Type T with which to match the key, eg: `key keyof T`. If the key is not present in T it will not allow compilation.\n\n# Dictionary definition\nA dictionary an object with a key for each language supported by the dictionary. Each language should be an object with signature *key: string, value: string*.\n\nOptionally a prefix key can also be supplied, in which case it will be used to prefix every key in the dictionary to avoid collissions with other dictionaries keys.  \n***NOTE:** You will have to prefix all keys in your invokations of* oh.translate *with the same value. This can be done by wrapping the* oh.translate *function in a separate function which automatically adds the prefix.*\n\n### Example dictionary\n```\n{\n    sv-SE: {\n        email: \"epost\",\n        name: \"namn\",\n        ...\n    },\n    en-US: {\n        email: \"email\",\n        name: \"name\",\n        ...\n    },\n    prefix: \"my-prefix\"\n}\n```\n\n### Example wrapper\n```\nfunction translate(str) {\n    return oh.translate(prefix + str);\n}\n```\n","readmeFilename":"README.md"}