Naturally Pacifist Marsupials
    Have ideas to improve npm?Join in the discussion! »

    docvy-utils

    0.2.0 • Public • Published

    docvy-utils

    node npm Travis Gemnasium Coveralls

    installation:

    ⇒ npm install docvy-utils

    the utilities:

    var utils = require("docvy-utils");

    The exported module object has all the properties from the built-in util module i.e. require("util") is cloned to the above export module object.

    utils.defineCallback([callback])

    Always returns a function that can be used in place of a callback, if none has been passed in your function. This is a convenience function that avoids the need to keep checking if a callback was passed before calling it, in program logic.

    • callback (Function):
      • you would normally pass the parameter suspected to be the callback.
      • if it is not a function, a new function will returned instead.

    utils.defineError(code, message)

    Generates a new Error class that can be used to instantiate a new error.

    • code (String): error code e.g. "ECODE"
    • message (String): error message e.g. "error message due to null argument"

    utils.errors

    This holds a reference to the common-errors module.

    utils.getPath(pathname)

    Returns application-specific paths. These paths are absolute.

    • pathname (String):
      • can be any of:
        • app.home: application user/home directory
        • app.cache: directory for all application caches
        • app.cache.plugins: directory for plugin handler's cache
        • app.logs: directory for logs
        • app.plugins: directory for user-installed plugins
      • if it does not match any of the above, null is returned.

    Note: The target path is created if not yet existent.

    utils.loadConfig(abspath)

    Loads a configuration file at the absolute path abspath. Note: an error is thrown if the path is broken or if the file pointed by the path does not have valid JSON.

    An immutable object is returned.

    license:

    The MIT License (MIT)

    Copyright (c) 2015 Forfuture we@forfuture.co.ke
    Copyright (c) 2015 GochoMugo mugo@forfuture.co.ke

    Keywords

    Install

    npm i docvy-utils

    DownloadsWeekly Downloads

    4

    Version

    0.2.0

    License

    MIT

    Last publish

    Collaborators

    • avatar
    • avatar