<commit_before>'use strict';

class DropdownList {
  constructor(element) {
    this.element = element;
    this.dropdownCollapseLabel = '.dropdown-list__item--collapse > .dropdown-list__label';
    this.dropdownItem = [...this.element.querySelectorAll(this.dropdownCollapseLabel)];
    this.contentClass = 'dropdown-list__content';
    this.mq = '(min-width: 768px)';
    this.mqClass = 'dropdown-list--is-open@screen-m';
    this.dropdownMediumOpen = this.element.classList.contains(this.mqClass);
    this.init();
  }

  setAriaAttributes(label, content, expanded) {
    if (expanded) {
      label.setAttribute('aria-expanded', 'false');
      content.setAttribute('aria-hidden', 'true');
    }
    else {
      label.setAttribute('aria-expanded', 'true');
      content.setAttribute('aria-hidden', 'false');
    }
  }

  removeAriaAttributes(label, content) {
    label.removeAttribute('aria-expanded');
    content.setAttribute('aria-hidden', 'false');
    label.disabled = true;
  }

  isMediumOpen(dropdownBlock) {
    return (dropdownBlock.classList.contains('dropdown-list--is-open@screen-m')) && window.matchMedia(this.mq).matches;
  }

  resetMqMediumOpen(item) {
    const dropdownItem    = item.parentNode,
          dropdownContent = dropdownItem.querySelector(`.${this.contentClass}`);

    if (window.matchMedia(this.mq).matches) {
      dropdownContent.style.height = 'auto';
      this.removeAriaAttributes(item, dropdownContent);
    }
    else {
      dropdownContent.style.height = 0;
      this.setAriaAttributes(item, dropdownContent, true);
      item.disabled = false;
    }
  }

  getContentHeight(item) {
    return [...item.children]
      .map(elem => elem.clientHeight)
      .reduce((a, b) => a + b, 0) + 'px';
  }

  closeInnerdDropdowns(item) {
    const subDropDowns = [...item.querySelectorAll(`${this.dropdownCollapseLabel}[aria-expanded="true"]`)];
    subDropDowns.forEach(key => {
      const dropdownId      = key.getAttribute('aria-controls'),
            dropdownItem    = key.parentNode,
            dropdownContent = dropdownItem.querySelector(`.${this.contentClass}[data-content="${dropdownId}"]`);
      this.setAriaAttributes(key, dropdownContent, true);
      dropdownContent.style.height = 0;
    });
  }

  toggleContent(item) {
    const dropdownId      = item.getAttribute('aria-controls'),
          dropdownItem    = item.parentNode,
          dropdownContent = dropdownItem.querySelector(`.${this.contentClass}[data-content="${dropdownId}"]`),
          dropdownBlock   = item.closest('.dropdown-list');

    if (!this.isMediumOpen(dropdownBlock)) {
      if (dropdownContent.clientHeight > 0) {
        const sectionHeight     = this.getContentHeight(dropdownContent),
              elementTransition = dropdownContent.style.transition;
        dropdownContent.style.transition = '';
        this.setAriaAttributes(item, dropdownContent, true);
        requestAnimationFrame(() => {
          dropdownContent.style.height = sectionHeight;
          dropdownContent.style.transition = elementTransition;
          requestAnimationFrame(() => {
            dropdownContent.style.height = 0 + 'px';
            this.closeInnerdDropdowns(dropdownContent);
          });
        });
      }
      else {
        const openedDropdowns = [...document.querySelectorAll('.dropdown-list__content[aria-hidden="false"]')];
        dropdownContent.style.height = this.getContentHeight(dropdownContent);
        openedDropdowns.map(openedDropdown => {
          openedDropdown.style.height = 'auto';
        });
        this.setAriaAttributes(item, dropdownContent, false);
      }
    }
  }

  setMediumOpen() {
    if (this.dropdownMediumOpen) {
      let dropdownItems = [...this.element.querySelectorAll(this.dropdownCollapseLabel)];
      dropdownItems.forEach(key => this.resetMqMediumOpen(key));
    }
  }

  init() {
    this.dropdownItem.forEach(
      key => key.addEventListener('click', (e) => {
        e.preventDefault();
        this.toggleContent(key);
      }, false)
    );
    this.setMediumOpen();

    window.addEventListener('resize', () => {
      this.setMediumOpen();
    });
  }
}

new DropdownList(document.querySelector('.dropdown-list'));
<commit_msg>#40448: remove unit for 0 value<commit_after>'use strict';

class DropdownList {
  constructor(element) {
    this.element = element;
    this.dropdownCollapseLabel = '.dropdown-list__item--collapse > .dropdown-list__label';
    this.dropdownItem = [...this.element.querySelectorAll(this.dropdownCollapseLabel)];
    this.contentClass = 'dropdown-list__content';
    this.mq = '(min-width: 768px)';
    this.mqClass = 'dropdown-list--is-open@screen-m';
    this.dropdownMediumOpen = this.element.classList.contains(this.mqClass);
    this.init();
  }

  setAriaAttributes(label, content, expanded) {
    if (expanded) {
      label.setAttribute('aria-expanded', 'false');
      content.setAttribute('aria-hidden', 'true');
    }
    else {
      label.setAttribute('aria-expanded', 'true');
      content.setAttribute('aria-hidden', 'false');
    }
  }

  removeAriaAttributes(label, content) {
    label.removeAttribute('aria-expanded');
    content.setAttribute('aria-hidden', 'false');
    label.disabled = true;
  }

  isMediumOpen(dropdownBlock) {
    return (dropdownBlock.classList.contains('dropdown-list--is-open@screen-m')) && window.matchMedia(this.mq).matches;
  }

  resetMqMediumOpen(item) {
    const dropdownItem    = item.parentNode,
          dropdownContent = dropdownItem.querySelector(`.${this.contentClass}`);

    if (window.matchMedia(this.mq).matches) {
      dropdownContent.style.height = 'auto';
      this.removeAriaAttributes(item, dropdownContent);
    }
    else {
      dropdownContent.style.height = 0;
      this.setAriaAttributes(item, dropdownContent, true);
      item.disabled = false;
    }
  }

  getContentHeight(item) {
    return [...item.children]
      .map(elem => elem.clientHeight)
      .reduce((a, b) => a + b, 0) + 'px';
  }

  closeInnerdDropdowns(item) {
    const subDropDowns = [...item.querySelectorAll(`${this.dropdownCollapseLabel}[aria-expanded="true"]`)];
    subDropDowns.forEach(key => {
      const dropdownId      = key.getAttribute('aria-controls'),
            dropdownItem    = key.parentNode,
            dropdownContent = dropdownItem.querySelector(`.${this.contentClass}[data-content="${dropdownId}"]`);
      this.setAriaAttributes(key, dropdownContent, true);
      dropdownContent.style.height = 0;
    });
  }

  toggleContent(item) {
    const dropdownId      = item.getAttribute('aria-controls'),
          dropdownItem    = item.parentNode,
          dropdownContent = dropdownItem.querySelector(`.${this.contentClass}[data-content="${dropdownId}"]`),
          dropdownBlock   = item.closest('.dropdown-list');

    if (!this.isMediumOpen(dropdownBlock)) {
      if (dropdownContent.clientHeight > 0) {
        const sectionHeight     = this.getContentHeight(dropdownContent),
              elementTransition = dropdownContent.style.transition;
        dropdownContent.style.transition = '';
        this.setAriaAttributes(item, dropdownContent, true);
        requestAnimationFrame(() => {
          dropdownContent.style.height = sectionHeight;
          dropdownContent.style.transition = elementTransition;
          requestAnimationFrame(() => {
            dropdownContent.style.height = 0;
            this.closeInnerdDropdowns(dropdownContent);
          });
        });
      }
      else {
        const openedDropdowns = [...document.querySelectorAll('.dropdown-list__content[aria-hidden="false"]')];
        dropdownContent.style.height = this.getContentHeight(dropdownContent);
        openedDropdowns.map(openedDropdown => {
          openedDropdown.style.height = 'auto';
        });
        this.setAriaAttributes(item, dropdownContent, false);
      }
    }
  }

  setMediumOpen() {
    if (this.dropdownMediumOpen) {
      let dropdownItems = [...this.element.querySelectorAll(this.dropdownCollapseLabel)];
      dropdownItems.forEach(key => this.resetMqMediumOpen(key));
    }
  }

  init() {
    this.dropdownItem.forEach(
      key => key.addEventListener('click', (e) => {
        e.preventDefault();
        this.toggleContent(key);
      }, false)
    );
    this.setMediumOpen();

    window.addEventListener('resize', () => {
      this.setMediumOpen();
    });
  }
}

new DropdownList(document.querySelector('.dropdown-list'));
<|endoftext|>


<commit_before>
/*!
 * EJS
 * Copyright(c) 2010 TJ Holowaychuk <tj@vision-media.ca>
 * MIT Licensed
 */

/**
 * Module dependencies.
 */

var sys = require('sys'),
    utils = require('./utils');

/**
 * Library version.
 */

exports.version = '0.2.0';

/**
 * Filters.
 *
 * @type Object
 */

var filters = exports.filters = require('./filters');

/**
 * Intermediate js cache.
 *
 * @type Object
 */

var cache = {};

/**
 * Clear intermediate js cache.
 *
 * @api public
 */

exports.clearCache = function(){
    cache = {};
};

/**
 * Translate filtered code into function calls.
 *
 * @param {String} js
 * @return {String}
 * @api private
 */

function filtered(js) {
    return js.substr(1).split('|').reduce(function(js, filter){
        var parts = filter.split(':'),
            name = parts.shift(),
            args = parts.shift() || '';
        if (args) args = ', ' + args;
        return 'filters.' + name + '(' + js + args + ')';
    });
}

/**
 * Parse the given `str` of ejs, returning the function body.
 *
 * @param {String} str
 * @return {String}
 * @api public
 */

var parse = exports.parse = function(str, options){
    var options = options || {},
        open = options.open || exports.open || '<%',
        close = options.close || exports.close || '%>';

    var buf = [
        "var buf = [];",
        "\nwith (locals) {",
        "\n  buf.push('"
    ];

    for (var i = 0, len = str.length; i < len; ++i) {
        if (str.slice(i, open.length + i) == open) {
            i += open.length

            var prefix, postfix;
            switch (str[i]) {
                case '=':
                    prefix = "', escape(";
                    postfix = "), '";
                    ++i;
                    break;
                case '-':
                    prefix = "', ";
                    postfix = ", '";
                    ++i;
                    break;
                default:
                    prefix = "'); ";
                    postfix = "; buf.push('";
            }

            var start = i;
            var end = str.indexOf(close, i);
            var js = str.substring(i, end);
            if (js[0] == ':') js = filtered(js);
            buf.push(prefix, js, postfix);
            i += end - start + close.length - 1;

        } else if (str[i] == "\\") {
            buf.push("\\\\");
        } else if (str[i] == "'") {
            buf.push("\\'");
        } else if (str[i] == "\r") {
            buf.push(" ");
        } else if (str[i] == "\n") {
            buf.push("\\n");
        } else {
            buf.push(str[i]);
        }
    }
    buf.push("');\n}\nreturn buf.join('');")
    return buf.join('')
};

/**
 * Compile the given `str` of ejs into a `Function`.
 *
 * @param {String} str
 * @param {Object} options
 * @return {Function}
 * @api public
 */

var compile = exports.compile = function(str, options){
    if (options.debug) sys.puts(parse(str));
    return function(locals){
        var fn = new Function('locals, filters, escape', parse(str, options));
        locals.__proto__ = filters;
        return fn.call(this, locals, filters, utils.escape);
    }
};

/**
 * Render the given `str` of ejs.
 *
 * Options:
 *
 *   - `locals`          Local variables object
 *   - `cache`           Compiled functions are cached, requires `filename`
 *   - `filename`        Used by `cache` to key caches
 *   - `context|scope`   Function execution context
 *   - `debug`           Output generated function body
 *   - `open`            Open tag, defaulting to "<%"
 *   - `close`           Closing tag, defaulting to "%>"
 *
 * @param {String} str
 * @param {Object} options
 * @return {String}
 * @api public
 */

exports.render = function(str, options){
    var fn,
        options = options || {};
    if (options.cache) {
        if (options.filename) {
            fn = cache[options.filename] = compile(str, options);
        } else {
            throw new Error('"cache" option requires "filename".');
        }
    } else {
        fn = compile(str, options);
    }
    return fn.call(options.context || options.scope, options.locals || {});
};
<commit_msg>Removed unused code<commit_after>
/*!
 * EJS
 * Copyright(c) 2010 TJ Holowaychuk <tj@vision-media.ca>
 * MIT Licensed
 */

/**
 * Module dependencies.
 */

var sys = require('sys'),
    utils = require('./utils');

/**
 * Library version.
 */

exports.version = '0.2.0';

/**
 * Filters.
 *
 * @type Object
 */

var filters = exports.filters = require('./filters');

/**
 * Intermediate js cache.
 *
 * @type Object
 */

var cache = {};

/**
 * Clear intermediate js cache.
 *
 * @api public
 */

exports.clearCache = function(){
    cache = {};
};

/**
 * Translate filtered code into function calls.
 *
 * @param {String} js
 * @return {String}
 * @api private
 */

function filtered(js) {
    return js.substr(1).split('|').reduce(function(js, filter){
        var parts = filter.split(':'),
            name = parts.shift(),
            args = parts.shift() || '';
        if (args) args = ', ' + args;
        return 'filters.' + name + '(' + js + args + ')';
    });
}

/**
 * Parse the given `str` of ejs, returning the function body.
 *
 * @param {String} str
 * @return {String}
 * @api public
 */

var parse = exports.parse = function(str, options){
    var options = options || {},
        open = options.open || exports.open || '<%',
        close = options.close || exports.close || '%>';

    var buf = [
        "var buf = [];",
        "\nwith (locals) {",
        "\n  buf.push('"
    ];

    for (var i = 0, len = str.length; i < len; ++i) {
        if (str.slice(i, open.length + i) == open) {
            i += open.length

            var prefix, postfix;
            switch (str[i]) {
                case '=':
                    prefix = "', escape(";
                    postfix = "), '";
                    ++i;
                    break;
                case '-':
                    prefix = "', ";
                    postfix = ", '";
                    ++i;
                    break;
                default:
                    prefix = "'); ";
                    postfix = "; buf.push('";
            }

            var start = i;
            var end = str.indexOf(close, i);
            var js = str.substring(i, end);
            if (js[0] == ':') js = filtered(js);
            buf.push(prefix, js, postfix);
            i += end - start + close.length - 1;

        } else if (str[i] == "\\") {
            buf.push("\\\\");
        } else if (str[i] == "'") {
            buf.push("\\'");
        } else if (str[i] == "\r") {
            buf.push(" ");
        } else if (str[i] == "\n") {
            buf.push("\\n");
        } else {
            buf.push(str[i]);
        }
    }
    buf.push("');\n}\nreturn buf.join('');")
    return buf.join('')
};

/**
 * Compile the given `str` of ejs into a `Function`.
 *
 * @param {String} str
 * @param {Object} options
 * @return {Function}
 * @api public
 */

var compile = exports.compile = function(str, options){
    if (options.debug) sys.puts(parse(str));
    return function(locals){
        var fn = new Function('locals, filters, escape', parse(str, options));
        return fn.call(this, locals, filters, utils.escape);
    }
};

/**
 * Render the given `str` of ejs.
 *
 * Options:
 *
 *   - `locals`          Local variables object
 *   - `cache`           Compiled functions are cached, requires `filename`
 *   - `filename`        Used by `cache` to key caches
 *   - `context|scope`   Function execution context
 *   - `debug`           Output generated function body
 *   - `open`            Open tag, defaulting to "<%"
 *   - `close`           Closing tag, defaulting to "%>"
 *
 * @param {String} str
 * @param {Object} options
 * @return {String}
 * @api public
 */

exports.render = function(str, options){
    var fn,
        options = options || {};
    if (options.cache) {
        if (options.filename) {
            fn = cache[options.filename] = compile(str, options);
        } else {
            throw new Error('"cache" option requires "filename".');
        }
    } else {
        fn = compile(str, options);
    }
    return fn.call(options.context || options.scope, options.locals || {});
};
<|endoftext|>


<commit_before>"use strict";
let splitargs = require("splitargs");
let which = require("which");
let Bluebird = require("bluebird");
let fs = require("fs-extra");
let path = require("path");
let _ = require("lodash");
let environment = require("./environment");
let Dist = require("./dist");
let CMLog = require("./cmLog");
let vsDetect = require("./vsDetect");
let TargetOptions = require("./targetOptions");
let processHelpers = require("./processHelpers");
let locateNAN = require("./locateNAN");
let npmConfigData = require("rc")("npm");
let async = Bluebird.coroutine;
let Toolset = require("./toolset");

function CMake(options) {
    this.options = options || {};
    this.log = new CMLog(this.options);
    this.dist = new Dist(this.options);
    this.projectRoot = path.resolve(this.options.directory || process.cwd());
    this.workDir = this.options.out || path.join(this.projectRoot, "build");
    this.config = this.options.debug ? "Debug" : "Release";
    this.buildDir = path.join(this.workDir, this.config);
    this._isAvailable = null;
    this.targetOptions = new TargetOptions(this.options);
    this.toolset = new Toolset(this.options);
    this.cMakeOptions = this.options.cMakeOptions || {};
    this.silent = !!options.silent;
}

Object.defineProperties(CMake.prototype, {
    path: {
        get: function () {
            return this.options.cmakePath || "cmake";
        }
    },
    isAvailable: {
        get: function () {
            if (this._isAvailable === null) {
                this._isAvailable = CMake.isAvailable(this.options);
            }
            return this._isAvailable;
        }
    }
});

CMake.isAvailable = function (options) {
    options = options || {};
    try {
        if (options.cmakePath) {
            let stat = fs.lstatSync(options.cmakePath);
            return !stat.isDirectory();
        }
        else {
            which.sync("cmake");
            return true;
        }
    }
    catch (e) {
        _.noop(e);
    }
    return false;
};

CMake.getGenerators = async(function* (options) {
    let arch = " [arch]";
    options = options || {};
    let gens = [];
    if (CMake.isAvailable(options)) {
        let stdout = yield processHelpers.exec((options.cmakePath || "cmake") + " --help");
        let hasCr = stdout.includes("\r\n");
        let output = hasCr ? stdout.split("\r\n") : stdout.split("\n");
        let on = false;
        output.forEach(function (line, i) {
            if (on) {
                let parts = line.split("=");
                if ((parts.length === 2 && parts[0].trim()) ||
                    (parts.length === 1 && i !== output.length - 1 && output[i + 1].trim()[0] === "=")) {
                    let gen = parts[0].trim();
                    if (_.endsWith(gen, arch)) {
                        gen = gen.substr(0, gen.length - arch.length);
                    }
                    gens.push(gen);
                }
            }
            if (line.trim() === "Generators") {
                on = true;
            }
        });
    }
    return gens;
});

CMake.prototype.getGenerators = function () {
    return CMake.getGenerators(this.options);
};

CMake.prototype.verifyIfAvailable = function () {
    if (!this.isAvailable) {
        throw new Error("CMake executable is not found. Please use your system's package manager to install it, or you can get installers from there: http://cmake.org.");
    }
};

CMake.prototype.getConfigureCommand = async(function* () {
    // Create command:
    let command = this.path;
    command += " \"" + this.projectRoot + "\" --no-warn-unused-cli";

    let D = [];

    // CMake.js watermark
    D.push({"CMAKE_JS_VERSION": environment.moduleVersion});

    // Build configuration:
    D.push({"CMAKE_BUILD_TYPE": this.config});
    if (environment.isWin) {
		D.push({"CMAKE_RUNTIME_OUTPUT_DIRECTORY": this.workDir});
	}
	else {
		D.push({"CMAKE_LIBRARY_OUTPUT_DIRECTORY": this.buildDir});
	}

    // Include and lib:
    let incPaths;
    if (this.dist.headerOnly) {
        incPaths = [path.join(this.dist.internalPath, "/include/node")];
    }
    else {
        let nodeH = path.join(this.dist.internalPath, "/src");
        let v8H = path.join(this.dist.internalPath, "/deps/v8/include");
        let uvH = path.join(this.dist.internalPath, "/deps/uv/include");
        incPaths = [nodeH, v8H, uvH];
    }

    // NAN
    let nanH = yield locateNAN(this.projectRoot);
    if (nanH) {
        incPaths.push(nanH);
    }

    // Includes:
    D.push({"CMAKE_JS_INC": incPaths.join(";")});

    // Runtime:
    D.push({"NODE_RUNTIME": this.targetOptions.runtime});
    D.push({"NODE_RUNTIMEVERSION": this.targetOptions.runtimeVersion});
    D.push({"NODE_ARCH": this.targetOptions.arch});

    if (environment.isWin) {
        // Win
        let libs = this.dist.winLibs;
        if (libs.length) {
            D.push({"CMAKE_JS_LIB": libs.join(";")});
        }
    }

    // Custom options
    for (let k of _.keys(this.cMakeOptions)) {
        D.push({[k]: this.cMakeOptions[k]});
    }

    // Toolset:
    yield this.toolset.initialize(false);

    if (this.toolset.generator) {
        command += " -G\"" + this.toolset.generator + "\"";
    }
    if (this.toolset.toolset) {
        command += " -T\"" + this.toolset.toolset + "\"";
    }
    if (this.toolset.cppCompilerPath) {
        D.push({"CMAKE_CXX_COMPILER": this.toolset.cppCompilerPath});
    }
    if (this.toolset.cCompilerPath) {
        D.push({"CMAKE_C_COMPILER": this.toolset.cCompilerPath});
    }
    if (this.toolset.compilerFlags.length) {
        D.push({"CMAKE_CXX_FLAGS": this.toolset.compilerFlags.join(" ")});
    }
    if (this.toolset.linkerFlags.length) {
        D.push({"CMAKE_SHARED_LINKER_FLAGS": this.toolset.linkerFlags.join(" ")});
    }
    if (this.toolset.makePath) {
        D.push({"CMAKE_MAKE_PROGRAM": this.toolset.makePath});
    }

    // Load NPM config
    npmConfigData = {};
    for (let key of _.keys(npmConfigData)) {
        let ukey = key.toUpperCase();
        if (_.startsWith(ukey, "CMAKE_")) {
            let s = {};
            let sk = ukey.substr(6);
            if (sk) {
                s[sk] = npmConfigData[key];
                if (s[sk]) {
                    D.push(s);
                }
            }
        }
    }

    command += " " +
        D.map(function (p) {
            return "-D" + _.keys(p)[0] + "=\"" + _.values(p)[0] + "\"";
        }).join(" ");

    return command;
});

CMake.prototype.configure = async(function* () {
    this.verifyIfAvailable();

    this.log.info("CMD", "CONFIGURE");
    let listPath = path.join(this.projectRoot, "CMakeLists.txt");
    let command = yield this.getConfigureCommand();

    try {
        yield fs.lstat(listPath);
    }
    catch (e) {
        throw new Error("'" + listPath + "' not found.");
    }

    try {
        yield fs.ensureDir(this.workDir);
    }
    catch (e) {
        _.noop(e);
    }

    let cwd = process.cwd();
    process.chdir(this.workDir);
    try {
        yield this._run(command);
    }
    finally {
        process.chdir(cwd);
    }
});

CMake.prototype.ensureConfigured = async(function* () {
    try {
        yield fs.lstat(path.join(this.workDir, "CMakeCache.txt"));
    }
    catch (e) {
        _.noop(e);
        yield this.configure();
    }
});

CMake.prototype.getBuildCommand = function() {
    var command = this.path + " --build \"" + this.workDir + "\" --config " + this.config;
    if (this.options.target) {
        command += " --target " + this.options.target;
    }
    return Bluebird.resolve(command);
};

CMake.prototype.build = async(function* () {
    this.verifyIfAvailable();

    yield this.ensureConfigured();
    let buildCommand = yield this.getBuildCommand();
    this.log.info("CMD", "BUILD");
    yield this._run(buildCommand);
});

CMake.prototype.getCleanCommand = function () {
    return this.path + " -E remove_directory \"" + this.workDir + "\"";
};

CMake.prototype.clean = function () {
    this.verifyIfAvailable();

    this.log.info("CMD", "CLEAN");
    return this._run(this.getCleanCommand());
};

CMake.prototype.reconfigure = async(function* () {
    yield this.clean();
    yield this.configure();
});

CMake.prototype.rebuild = async(function* () {
    yield this.clean();
    yield this.build();
});

CMake.prototype.compile = async(function* () {
    try {
        yield this.build();
    }
    catch (e) {
        _.noop(e);
        this.log.info("REP", "Build has been failed, trying to do a full rebuild.");
        yield this.rebuild();
    }
});

CMake.prototype._run = function (command) {
    this.log.info("RUN", command);
    return processHelpers.run(command, {silent: this.silent});
};

module.exports = CMake;
<commit_msg>remove incorrect initialization of npmConfigData to empty object (#123)<commit_after>"use strict";
let splitargs = require("splitargs");
let which = require("which");
let Bluebird = require("bluebird");
let fs = require("fs-extra");
let path = require("path");
let _ = require("lodash");
let environment = require("./environment");
let Dist = require("./dist");
let CMLog = require("./cmLog");
let vsDetect = require("./vsDetect");
let TargetOptions = require("./targetOptions");
let processHelpers = require("./processHelpers");
let locateNAN = require("./locateNAN");
let npmConfigData = require("rc")("npm");
let async = Bluebird.coroutine;
let Toolset = require("./toolset");

function CMake(options) {
    this.options = options || {};
    this.log = new CMLog(this.options);
    this.dist = new Dist(this.options);
    this.projectRoot = path.resolve(this.options.directory || process.cwd());
    this.workDir = this.options.out || path.join(this.projectRoot, "build");
    this.config = this.options.debug ? "Debug" : "Release";
    this.buildDir = path.join(this.workDir, this.config);
    this._isAvailable = null;
    this.targetOptions = new TargetOptions(this.options);
    this.toolset = new Toolset(this.options);
    this.cMakeOptions = this.options.cMakeOptions || {};
    this.silent = !!options.silent;
}

Object.defineProperties(CMake.prototype, {
    path: {
        get: function () {
            return this.options.cmakePath || "cmake";
        }
    },
    isAvailable: {
        get: function () {
            if (this._isAvailable === null) {
                this._isAvailable = CMake.isAvailable(this.options);
            }
            return this._isAvailable;
        }
    }
});

CMake.isAvailable = function (options) {
    options = options || {};
    try {
        if (options.cmakePath) {
            let stat = fs.lstatSync(options.cmakePath);
            return !stat.isDirectory();
        }
        else {
            which.sync("cmake");
            return true;
        }
    }
    catch (e) {
        _.noop(e);
    }
    return false;
};

CMake.getGenerators = async(function* (options) {
    let arch = " [arch]";
    options = options || {};
    let gens = [];
    if (CMake.isAvailable(options)) {
        let stdout = yield processHelpers.exec((options.cmakePath || "cmake") + " --help");
        let hasCr = stdout.includes("\r\n");
        let output = hasCr ? stdout.split("\r\n") : stdout.split("\n");
        let on = false;
        output.forEach(function (line, i) {
            if (on) {
                let parts = line.split("=");
                if ((parts.length === 2 && parts[0].trim()) ||
                    (parts.length === 1 && i !== output.length - 1 && output[i + 1].trim()[0] === "=")) {
                    let gen = parts[0].trim();
                    if (_.endsWith(gen, arch)) {
                        gen = gen.substr(0, gen.length - arch.length);
                    }
                    gens.push(gen);
                }
            }
            if (line.trim() === "Generators") {
                on = true;
            }
        });
    }
    return gens;
});

CMake.prototype.getGenerators = function () {
    return CMake.getGenerators(this.options);
};

CMake.prototype.verifyIfAvailable = function () {
    if (!this.isAvailable) {
        throw new Error("CMake executable is not found. Please use your system's package manager to install it, or you can get installers from there: http://cmake.org.");
    }
};

CMake.prototype.getConfigureCommand = async(function* () {
    // Create command:
    let command = this.path;
    command += " \"" + this.projectRoot + "\" --no-warn-unused-cli";

    let D = [];

    // CMake.js watermark
    D.push({"CMAKE_JS_VERSION": environment.moduleVersion});

    // Build configuration:
    D.push({"CMAKE_BUILD_TYPE": this.config});
    if (environment.isWin) {
		D.push({"CMAKE_RUNTIME_OUTPUT_DIRECTORY": this.workDir});
	}
	else {
		D.push({"CMAKE_LIBRARY_OUTPUT_DIRECTORY": this.buildDir});
	}

    // Include and lib:
    let incPaths;
    if (this.dist.headerOnly) {
        incPaths = [path.join(this.dist.internalPath, "/include/node")];
    }
    else {
        let nodeH = path.join(this.dist.internalPath, "/src");
        let v8H = path.join(this.dist.internalPath, "/deps/v8/include");
        let uvH = path.join(this.dist.internalPath, "/deps/uv/include");
        incPaths = [nodeH, v8H, uvH];
    }

    // NAN
    let nanH = yield locateNAN(this.projectRoot);
    if (nanH) {
        incPaths.push(nanH);
    }

    // Includes:
    D.push({"CMAKE_JS_INC": incPaths.join(";")});

    // Runtime:
    D.push({"NODE_RUNTIME": this.targetOptions.runtime});
    D.push({"NODE_RUNTIMEVERSION": this.targetOptions.runtimeVersion});
    D.push({"NODE_ARCH": this.targetOptions.arch});

    if (environment.isWin) {
        // Win
        let libs = this.dist.winLibs;
        if (libs.length) {
            D.push({"CMAKE_JS_LIB": libs.join(";")});
        }
    }

    // Custom options
    for (let k of _.keys(this.cMakeOptions)) {
        D.push({[k]: this.cMakeOptions[k]});
    }

    // Toolset:
    yield this.toolset.initialize(false);

    if (this.toolset.generator) {
        command += " -G\"" + this.toolset.generator + "\"";
    }
    if (this.toolset.toolset) {
        command += " -T\"" + this.toolset.toolset + "\"";
    }
    if (this.toolset.cppCompilerPath) {
        D.push({"CMAKE_CXX_COMPILER": this.toolset.cppCompilerPath});
    }
    if (this.toolset.cCompilerPath) {
        D.push({"CMAKE_C_COMPILER": this.toolset.cCompilerPath});
    }
    if (this.toolset.compilerFlags.length) {
        D.push({"CMAKE_CXX_FLAGS": this.toolset.compilerFlags.join(" ")});
    }
    if (this.toolset.linkerFlags.length) {
        D.push({"CMAKE_SHARED_LINKER_FLAGS": this.toolset.linkerFlags.join(" ")});
    }
    if (this.toolset.makePath) {
        D.push({"CMAKE_MAKE_PROGRAM": this.toolset.makePath});
    }

    // Load NPM config
    for (let key of _.keys(npmConfigData)) {
        let ukey = key.toUpperCase();
        if (_.startsWith(ukey, "CMAKE_")) {
            let s = {};
            let sk = ukey.substr(6);
            if (sk) {
                s[sk] = npmConfigData[key];
                if (s[sk]) {
                    D.push(s);
                }
            }
        }
    }

    command += " " +
        D.map(function (p) {
            return "-D" + _.keys(p)[0] + "=\"" + _.values(p)[0] + "\"";
        }).join(" ");

    return command;
});

CMake.prototype.configure = async(function* () {
    this.verifyIfAvailable();

    this.log.info("CMD", "CONFIGURE");
    let listPath = path.join(this.projectRoot, "CMakeLists.txt");
    let command = yield this.getConfigureCommand();

    try {
        yield fs.lstat(listPath);
    }
    catch (e) {
        throw new Error("'" + listPath + "' not found.");
    }

    try {
        yield fs.ensureDir(this.workDir);
    }
    catch (e) {
        _.noop(e);
    }

    let cwd = process.cwd();
    process.chdir(this.workDir);
    try {
        yield this._run(command);
    }
    finally {
        process.chdir(cwd);
    }
});

CMake.prototype.ensureConfigured = async(function* () {
    try {
        yield fs.lstat(path.join(this.workDir, "CMakeCache.txt"));
    }
    catch (e) {
        _.noop(e);
        yield this.configure();
    }
});

CMake.prototype.getBuildCommand = function() {
    var command = this.path + " --build \"" + this.workDir + "\" --config " + this.config;
    if (this.options.target) {
        command += " --target " + this.options.target;
    }
    return Bluebird.resolve(command);
};

CMake.prototype.build = async(function* () {
    this.verifyIfAvailable();

    yield this.ensureConfigured();
    let buildCommand = yield this.getBuildCommand();
    this.log.info("CMD", "BUILD");
    yield this._run(buildCommand);
});

CMake.prototype.getCleanCommand = function () {
    return this.path + " -E remove_directory \"" + this.workDir + "\"";
};

CMake.prototype.clean = function () {
    this.verifyIfAvailable();

    this.log.info("CMD", "CLEAN");
    return this._run(this.getCleanCommand());
};

CMake.prototype.reconfigure = async(function* () {
    yield this.clean();
    yield this.configure();
});

CMake.prototype.rebuild = async(function* () {
    yield this.clean();
    yield this.build();
});

CMake.prototype.compile = async(function* () {
    try {
        yield this.build();
    }
    catch (e) {
        _.noop(e);
        this.log.info("REP", "Build has been failed, trying to do a full rebuild.");
        yield this.rebuild();
    }
});

CMake.prototype._run = function (command) {
    this.log.info("RUN", command);
    return processHelpers.run(command, {silent: this.silent});
};

module.exports = CMake;
<|endoftext|>


<commit_before>'use strict';

/**
 * Module dependencies.
 */

var mongoose = require('mongoose');
var assert = require('assert');
var _ = require('lodash');

var	Order = mongoose.model('Order'),
	Payment = mongoose.model('Payment');

/**
 * Get the error message from error object
 */
var getErrorMessage = function(err) {
	var message = '';

	if (err.code) {
		switch (err.code) {
			case 11000:
			case 11001:
				message = 'Order already exists';
				break;
			default:
				message = 'Something went wrong';
		}
	} else {
		for (var errName in err.errors) {
			if (err.errors[errName].message) message = err.errors[errName].message;
		}
	}

	return message;
};

/**
 * Create a Order
 */
//exports.create = function(req, res) {
//	var order = new Order(req.body);
//	order.user = req.user;
//
//	// orders can only be created in the new state and modifications are
//	// managed through contoller methods (no bare updates)
//    order.state = 'new';

//	order.save(function(err) {
//		if (err) {
//			return res.send(400, {
//				message: getErrorMessage(err)
//			});
//		} else {
//			res.jsonp(order);
//		}
//	});
//};

/**
 * Show the current Order
 */
exports.read = function(req, res) {
	res.jsonp(req.order);
};

/**
 * Delete an Order (don't actually delete it though)
 */
exports.delete = function(req, res) {
	var order = req.order ;

    order.state = 'deleted';
	order.save(function(err) {
		if (err) {
			return res.send(400, {
				message: getErrorMessage(err)
			});
		} else {
			res.jsonp(order);
		}
	});
};

/**
 * List of Orders (not deleted ones)
 */
exports.list = function(req, res) {
    Order.find({state: { $ne: 'deleted' }}).sort('-created')
        //.populate('user', 'displayName')
        .exec(function(err, orders) {
		    if (err) {
			    return res.send(400, {
				    message: getErrorMessage(err)
			    });
		    } else {
			    res.jsonp(orders);
		    }
	    });
};

exports.history = function(req, res, next) {
    var orders = req.orders;
    res.jsonp(orders);
};

exports.recalculate = function(req, res) {
    var order = req.order;

    order.calculateWithoutLookup();
    res.jsonp(order);
};

exports.recalculateWithLookup = function(req, res) {
    var order = req.order;

    order
        .calculate()
        .then(() => { res.jsonp(order); })
        .catch((err) => { res.status(400).send(err.message); });
};

exports.finalise = function(req, res) {
    var order = req.order;

    Promise.resolve()
        .then(() => {
            assert.equal(order.state, 'confirmed', 'Can only finalised confirmed orders');
        })
        .then(() => {
            var items = req.body;

            // Process each action
            _.forEach(items, (item) => {
                var orderItem = _.find(order.items, (oi) => { return oi._product.toString() === item.productId; } );
                assert.ok(orderItem, 'order item not found: ' + item.productId);
                assert.equal(orderItem.quantity, item.quantity, item.productId + 'quantity mismatch');
                switch(item.action) {
                    case 'cancel':
                        orderItem.state = 'cancelled';
                        break;
                    case 'finalise':
                        orderItem.state = 'finalised';
                        break;
                    default:
                        throw new Error('unrecognised action: ' + item.action);
                }
            });

        })
        .then(() => { order.calculateWithoutLookup(); })
        .then(() => {

            // Check order state
            var remaining = _.reject(order.items, (item) => {
                switch(item.state) {
                    case 'finalised':
                    case 'cancelled':
                    case 'refunded':
                        return true;
                    default:
                        return false;
                }
            });

            if (remaining.length === 0 ) {
                if (order.due === 0) {
                    order.state = 'closed';
                }
                else {
                    order.state = 'finalised';
                }
            }
            else {
                console.error('Order not finalised: ' + order._id);
            }
        })
        .then(() => { return order.save(); })
        .then(() => { res.jsonp(order); })
        .catch((err) => { res.status(400).send({ message: err.message }); });
};

/**
 * Order middleware
 */
exports.orderByID = function(req, res, next, id) {
    Order.findById(id)
        .where({state: { $ne: 'deleted' }})
            //.populate('user', 'displayName')
            .populate('payments')
            .exec(function(err, order) {
		        if (err) return next(err);
		        if (! order) return next(new Error('Failed to load Order ' + id));
		        req.order = order ;
		        next();
	        });
};

exports.ordersByUserID = function(req, res, next, id) {
    Order.find({state: { $ne: 'deleted' }, user: id })
//        .select('payments')
        .sort('-created')
        //.populate('user', 'displayName')
        .exec(function(err, orders) {
            if (err) return next(err);
            req.orders = orders;
            next();
	    });
};
<commit_msg>Use payment information to calculate order history totals but scrub payments from the output<commit_after>'use strict';

/**
 * Module dependencies.
 */

var mongoose = require('mongoose');
var assert = require('assert');
var _ = require('lodash');

var	Order = mongoose.model('Order'),
	Payment = mongoose.model('Payment');

/**
 * Get the error message from error object
 */
var getErrorMessage = function(err) {
	var message = '';

	if (err.code) {
		switch (err.code) {
			case 11000:
			case 11001:
				message = 'Order already exists';
				break;
			default:
				message = 'Something went wrong';
		}
	} else {
		for (var errName in err.errors) {
			if (err.errors[errName].message) message = err.errors[errName].message;
		}
	}

	return message;
};

/**
 * Create a Order
 */
//exports.create = function(req, res) {
//	var order = new Order(req.body);
//	order.user = req.user;
//
//	// orders can only be created in the new state and modifications are
//	// managed through contoller methods (no bare updates)
//    order.state = 'new';

//	order.save(function(err) {
//		if (err) {
//			return res.send(400, {
//				message: getErrorMessage(err)
//			});
//		} else {
//			res.jsonp(order);
//		}
//	});
//};

/**
 * Show the current Order
 */
exports.read = function(req, res) {
	res.jsonp(req.order);
};

/**
 * Delete an Order (don't actually delete it though)
 */
exports.delete = function(req, res) {
	var order = req.order ;

    order.state = 'deleted';
	order.save(function(err) {
		if (err) {
			return res.send(400, {
				message: getErrorMessage(err)
			});
		} else {
			res.jsonp(order);
		}
	});
};

/**
 * List of Orders (not deleted ones)
 */
exports.list = function(req, res) {
    Order.find({state: { $ne: 'deleted' }}).sort('-created')
        //.populate('user', 'displayName')
        .exec(function(err, orders) {
		    if (err) {
			    return res.send(400, {
				    message: getErrorMessage(err)
			    });
		    } else {
			    res.jsonp(orders);
		    }
	    });
};

exports.history = function(req, res, next) {
    var orders = req.orders;
    res.jsonp(_.map(orders,(order) => { return _.omit(order,'payments'); }));
};

exports.recalculate = function(req, res) {
    var order = req.order;

    order.calculateWithoutLookup();
    res.jsonp(order);
};

exports.recalculateWithLookup = function(req, res) {
    var order = req.order;

    order
        .calculate()
        .then(() => { res.jsonp(order); })
        .catch((err) => { res.status(400).send(err.message); });
};

exports.finalise = function(req, res) {
    var order = req.order;

    Promise.resolve()
        .then(() => {
            assert.equal(order.state, 'confirmed', 'Can only finalised confirmed orders');
        })
        .then(() => {
            var items = req.body;

            // Process each action
            _.forEach(items, (item) => {
                var orderItem = _.find(order.items, (oi) => { return oi._product.toString() === item.productId; } );
                assert.ok(orderItem, 'order item not found: ' + item.productId);
                assert.equal(orderItem.quantity, item.quantity, item.productId + 'quantity mismatch');
                switch(item.action) {
                    case 'cancel':
                        orderItem.state = 'cancelled';
                        break;
                    case 'finalise':
                        orderItem.state = 'finalised';
                        break;
                    default:
                        throw new Error('unrecognised action: ' + item.action);
                }
            });

        })
        .then(() => { order.calculateWithoutLookup(); })
        .then(() => {

            // Check order state
            var remaining = _.reject(order.items, (item) => {
                switch(item.state) {
                    case 'finalised':
                    case 'cancelled':
                    case 'refunded':
                        return true;
                    default:
                        return false;
                }
            });

            if (remaining.length === 0 ) {
                if (order.due === 0) {
                    order.state = 'closed';
                }
                else {
                    order.state = 'finalised';
                }
            }
            else {
                console.error('Order not finalised: ' + order._id);
            }
        })
        .then(() => { return order.save(); })
        .then(() => { res.jsonp(order); })
        .catch((err) => { res.status(400).send({ message: err.message }); });
};

/**
 * Order middleware
 */
exports.orderByID = function(req, res, next, id) {
    Order.findById(id)
        .where({state: { $ne: 'deleted' }})
            //.populate('user', 'displayName')
            .populate('payments')
            .exec(function(err, order) {
		        if (err) return next(err);
		        if (! order) return next(new Error('Failed to load Order ' + id));
		        req.order = order ;
		        next();
	        });
};

exports.ordersByUserID = function(req, res, next, id) {
    Order.find({state: { $ne: 'deleted' }, user: id })
//        .select('payments')
        .sort('-created')
        .populate('payments')
        //.populate('user', 'displayName')
        .exec(function(err, orders) {
            if (err) return next(err);
            req.orders = orders;
            next();
	    });
};
<|endoftext|>


<commit_before>var groupOffset = 0
var types = module.exports = {}

addGroup({
  tx: {
    new: 0,
    confirmation: 1
  }
})

addGroup({
  msg: {
    new: 0,
    // stored: 1,
    sendSuccess: 2,
    sendError: 3,
    delivered: 4,
    receivedValid: 5,
    receivedInvalid: 6
  }
})

addGroup({
  chain: {
    readSuccess: 0,
    readError: 1,
    writeSuccess: 2,
    writeError: 3
  }
})

function addGroup (group) {
  groupOffset += 1000
  enumerate(group, 0)
  for (var p in group) {
    types[p] = group[p]
  }
}

function enumerate (group, offset) {
  for (var p in group) {
    var sub = group[p]
    if (typeof sub === 'number') {
      group[p] += groupOffset
    } else {
      enumerate(sub, offset)
    }
  }
}
<commit_msg>support reverse lookup of event types (for more sensical logging)<commit_after>// var groupOffset = 0
var types = module.exports = {}
var reverse = exports.reverse = {}

;[
  {
    group: 'tx',
    events: {
      new: 0,
      confirmation: 1
    }
  },
  {
    group: 'msg',
    events: {
      new: 0,
      // stored: 1,
      sendSuccess: 2,
      sendError: 3,
      delivered: 4,
      receivedValid: 5,
      receivedInvalid: 6
    }
  },
  {
    group: 'chain',
    events: {
      readSuccess: 0,
      readError: 1,
      writeSuccess: 2,
      writeError: 3
    }
  }
].forEach(function (group, i) {
  var offset = 1000 * (i + 1)
  var g = types[group.group] = {}
  for (var event in group.events) {
    var code = offset + group.events[event]
    g[event] = code
    reverse[code] = group.group + '.' + event
  }
})

// addGroup({
//   tx: {
//     new: 0,
//     confirmation: 1
//   }
// })

// addGroup({
//   msg: {
//     new: 0,
//     // stored: 1,
//     sendSuccess: 2,
//     sendError: 3,
//     delivered: 4,
//     receivedValid: 5,
//     receivedInvalid: 6
//   }
// })

// addGroup({
//   chain: {
//     readSuccess: 0,
//     readError: 1,
//     writeSuccess: 2,
//     writeError: 3
//   }
// })

// function addGroup (group) {
//   groupOffset += 1000
//   enumerate(group, 0)
//   for (var p in group) {
//     types[p] = group[p]
//   }
// }

// function enumerate (group, offset) {
//   for (var p in group) {
//     var sub = group[p]
//     if (typeof sub === 'number') {
//       group[p] += groupOffset
//     } else {
//       enumerate(sub, offset)
//     }
//   }
// }
<|endoftext|>


<commit_before>'use strict';

angular.module('app')
    .controller('rgiDocumentTableCtrl', function (
        _,
        $scope,
        $rootScope,
        rgiDialogFactory,
        rgiAssessmentSrvc,
        rgiDocumentSrvc,
        rgiHttpResponseProcessorSrvc,
        rgiNotifier
    ) {
        var currentPage, totalPages, limit = 100;

        $scope.busy = false;
        $scope.assessment_filter_options = [];
        $scope.assessment_filter = '';

        rgiAssessmentSrvc.query({}, function (assessments) {
            if(assessments.reason) {
                rgiNotifier.error('No assessments');
            } else {
                assessments.forEach(function(assessment) {
                    $scope.assessment_filter_options.push({
                        value: assessment.assessment_ID,
                        text: assessment.country + ' ' + assessment.year + ' ' + assessment.version
                    });
                });
            }
        });

        $scope.$watch('assessment_filter', function(assessment) {
            currentPage = 0;
            totalPages = 0;
            var searchOptions = {skip: currentPage, limit: limit};

            if(assessment) {
                searchOptions.assessments = assessment;
            }

            rgiDocumentSrvc.queryCached(searchOptions, function (response) {
                if(response.reason) {
                    rgiNotifier.error('Load document data failure');
                } else {
                    $scope.count = response.count;
                    $scope.documents = response.data;

                    if($scope.documents.length === 0) {
                        rgiNotifier.error('No documents uploaded');
                    }

                    totalPages = Math.ceil(response.count / limit);
                    currentPage = 1;
                }
            }, rgiHttpResponseProcessorSrvc.getDefaultHandler('Load document data failure'));
        });

        $scope.loadMoreDocs = function() {
            if ($scope.busy) {
                return;
            }

            $scope.busy = true;

            if(currentPage < totalPages) {
                var searchOptions = {skip: currentPage, limit: limit};

                if($scope.assessment_filter) {
                    searchOptions.assessments = $scope.assessment_filter;
                }

                rgiDocumentSrvc.query(searchOptions, function (response) {
                    if(response.reason) {
                        rgiNotifier.error('Documents loading failure');
                    } else {
                        $scope.documents = _.union($scope.documents, response.data);
                        currentPage = currentPage + 1;
                        $scope.busy = false;
                    }
                }, rgiHttpResponseProcessorSrvc.getDefaultHandler('Load document data failure'));
            }
        };

        $scope.deleteDocument = function(doc) {
            rgiDialogFactory.deleteDocument($scope, doc);
        };
    });
<commit_msg>add 'Unlink Document' feature<commit_after>'use strict';

angular.module('app')
    .controller('rgiDocumentTableCtrl', ['_', '$scope', '$rootScope', 'rgiDialogFactory', 'rgiAssessmentSrvc', 'rgiDocumentSrvc', 'rgiHttpResponseProcessorSrvc', 'rgiNotifier', function (
        _,
        $scope,
        $rootScope,
        rgiDialogFactory,
        rgiAssessmentSrvc,
        rgiDocumentSrvc,
        rgiHttpResponseProcessorSrvc,
        rgiNotifier
    ) {
        var currentPage, totalPages, limit = 100;

        $scope.busy = false;
        $scope.assessment_filter_options = [];
        $scope.assessment_filter = '';

        rgiAssessmentSrvc.query({}, function (assessments) {
            if(assessments.reason) {
                rgiNotifier.error('No assessments');
            } else {
                assessments.forEach(function(assessment) {
                    $scope.assessment_filter_options.push({
                        value: assessment.assessment_ID,
                        text: assessment.country + ' ' + assessment.year + ' ' + assessment.version
                    });
                });
            }
        });

        $scope.$watch('assessment_filter', function(assessment) {
            currentPage = 0;
            totalPages = 0;
            var searchOptions = {skip: currentPage, limit: limit};

            if(assessment) {
                searchOptions.assessments = assessment;
            }

            rgiDocumentSrvc.queryCached(searchOptions, function (response) {
                if(response.reason) {
                    rgiNotifier.error('Load document data failure');
                } else {
                    $scope.count = response.count;
                    $scope.documents = response.data;

                    if($scope.documents.length === 0) {
                        rgiNotifier.error('No documents uploaded');
                    }

                    totalPages = Math.ceil(response.count / limit);
                    currentPage = 1;
                }
            }, rgiHttpResponseProcessorSrvc.getDefaultHandler('Load document data failure'));
        });

        $scope.loadMoreDocs = function() {
            if ($scope.busy) {
                return;
            }

            $scope.busy = true;

            if(currentPage < totalPages) {
                var searchOptions = {skip: currentPage, limit: limit};

                if($scope.assessment_filter) {
                    searchOptions.assessments = $scope.assessment_filter;
                }

                rgiDocumentSrvc.query(searchOptions, function (response) {
                    if(response.reason) {
                        rgiNotifier.error('Documents loading failure');
                    } else {
                        $scope.documents = _.union($scope.documents, response.data);
                        currentPage = currentPage + 1;
                        $scope.busy = false;
                    }
                }, rgiHttpResponseProcessorSrvc.getDefaultHandler('Load document data failure'));
            }
        };

        $scope.deleteDocument = function(doc) {
            rgiDialogFactory.deleteDocument($scope, doc);
        };

        $scope.unlink = function(doc) {
            rgiDialogFactory.unlinkDocument($scope, doc);
        };
    }]);
<|endoftext|>


<commit_before>'use strict';

angular.module('app')
    .controller('rgiDocumentTableCtrl', function (
        _,
        $scope,
        $rootScope,
        rgiDialogFactory,
        rgiAssessmentSrvc,
        rgiDocumentSrvc,
        rgiHttpResponseProcessorSrvc,
        rgiIdentitySrvc,
        rgiNotifier
    ) {
        var limit = 100,
            currentPage = 0,
            totalPages = 0;

        $scope.current_user = rgiIdentitySrvc.currentUser;
        $scope.busy = false;

        $scope.assessment_filter_options = [
            {value: 'all', text: 'Show all documents'}
            // {value: 'type', text: 'Sort by document type'},
            // {value: 'assessments', text: 'Sort by attached assessments'}
        ];

        $scope.assessment_filter = $scope.assessment_filter_options[0].value;

        rgiAssessmentSrvc.query({}, function (assessments) {
            if(assessments.reason) {
                rgiNotifier.error('No assessments');
            } else {
                assessments.forEach(function(assessment) {
                    console.log(assessment);
                    $scope.assessment_filter_options.push({
                        value: assessment.assessment_ID,
                        text: assessment.country + ' ' + assessment.year + ' ' + assessment.version
                    });
                });
            }
        });

        rgiDocumentSrvc.query({skip: currentPage, limit: limit}, function (response) {
            if(response.reason) {
                rgiNotifier.error('Load document data failure');
            } else {
                $scope.count = response.count;
                $scope.documents = response.data;
                totalPages = Math.ceil(response.count / limit);
                currentPage = currentPage + 1;
            }
        }, rgiHttpResponseProcessorSrvc.getDefaultHandler('Load document data failure'));

        $scope.loadMoreDocs = function() {
            if ($scope.busy) {
                return;
            }

            $scope.busy = true;

            if(currentPage < totalPages) {
                rgiDocumentSrvc.query({skip: currentPage, limit: limit}, function (response) {
                    if(response.reason) {
                        rgiNotifier.error('Documents loading failure');
                    } else {
                        $scope.documents = _.union($scope.documents, response.data);
                        currentPage = currentPage + 1;
                        $scope.busy = false;
                    }
                }, rgiHttpResponseProcessorSrvc.getDefaultHandler('Load document data failure'));
            }
        };

        $scope.deleteDocument = function(doc) {
            rgiDialogFactory.deleteDocument($scope, doc);
        };
    });
<commit_msg>fix the 'Document Table' directive controller<commit_after>'use strict';

angular.module('app')
    .controller('rgiDocumentTableCtrl', function (
        _,
        $scope,
        $rootScope,
        rgiDialogFactory,
        rgiAssessmentSrvc,
        rgiDocumentSrvc,
        rgiHttpResponseProcessorSrvc,
        rgiNotifier
    ) {
        var currentPage, totalPages, limit = 100;

        $scope.busy = false;
        $scope.assessment_filter_options = [];
        $scope.assessment_filter = '';

        rgiAssessmentSrvc.query({}, function (assessments) {
            if(assessments.reason) {
                rgiNotifier.error('No assessments');
            } else {
                assessments.forEach(function(assessment) {
                    $scope.assessment_filter_options.push({
                        value: assessment.assessment_ID,
                        text: assessment.country + ' ' + assessment.year + ' ' + assessment.version
                    });
                });
            }
        });

        $scope.$watch('assessment_filter', function(assessment) {
            currentPage = 0;
            totalPages = 0;
            var searchOptions = {skip: currentPage, limit: limit};

            if(assessment) {
                searchOptions.assessments = assessment;
            }

            rgiDocumentSrvc.queryCached(searchOptions, function (response) {
                if(response.reason) {
                    rgiNotifier.error('Load document data failure');
                } else {
                    $scope.count = response.count;
                    $scope.documents = response.data;

                    if($scope.documents.length === 0) {
                        rgiNotifier.error('No documents uploaded');
                    }

                    totalPages = Math.ceil(response.count / limit);
                    currentPage = 1;
                }
            }, rgiHttpResponseProcessorSrvc.getDefaultHandler('Load document data failure'));
        });

        $scope.loadMoreDocs = function() {
            if ($scope.busy) {
                return;
            }

            $scope.busy = true;

            if(currentPage < totalPages) {
                var searchOptions = {skip: currentPage, limit: limit};

                if($scope.assessment_filter) {
                    searchOptions.assessments = $scope.assessment_filter;
                }

                rgiDocumentSrvc.query(searchOptions, function (response) {
                    if(response.reason) {
                        rgiNotifier.error('Documents loading failure');
                    } else {
                        $scope.documents = _.union($scope.documents, response.data);
                        currentPage = currentPage + 1;
                        $scope.busy = false;
                    }
                }, rgiHttpResponseProcessorSrvc.getDefaultHandler('Load document data failure'));
            }
        };

        $scope.deleteDocument = function(doc) {
            rgiDialogFactory.deleteDocument($scope, doc);
        };
    });
<|endoftext|>


<commit_before>'use strict';

angular.module('app')
    .controller('rgiDocumentTableCtrl', function (
        _,
        $scope,
        $rootScope,
        rgiDialogFactory,
        rgiAssessmentSrvc,
        rgiDocumentSrvc,
        rgiHttpResponseProcessorSrvc,
        rgiNotifier
    ) {
        var currentPage, totalPages, limit = 100;

        $scope.busy = false;
        $scope.assessment_filter_options = [];
        $scope.assessment_filter = '';

        rgiAssessmentSrvc.query({}, function (assessments) {
            if(assessments.reason) {
                rgiNotifier.error('No assessments');
            } else {
                assessments.forEach(function(assessment) {
                    $scope.assessment_filter_options.push({
                        value: assessment.assessment_ID,
                        text: assessment.country + ' ' + assessment.year + ' ' + assessment.version
                    });
                });
            }
        });

        $scope.$watch('assessment_filter', function(assessment) {
            currentPage = 0;
            totalPages = 0;
            var searchOptions = {skip: currentPage, limit: limit};

            if(assessment) {
                searchOptions.assessments = assessment;
            }

            rgiDocumentSrvc.queryCached(searchOptions, function (response) {
                if(response.reason) {
                    rgiNotifier.error('Load document data failure');
                } else {
                    $scope.count = response.count;
                    $scope.documents = response.data;

                    if($scope.documents.length === 0) {
                        rgiNotifier.error('No documents uploaded');
                    }

                    totalPages = Math.ceil(response.count / limit);
                    currentPage = 1;
                }
            }, rgiHttpResponseProcessorSrvc.getDefaultHandler('Load document data failure'));
        });

        $scope.loadMoreDocs = function() {
            if ($scope.busy) {
                return;
            }

            $scope.busy = true;

            if(currentPage < totalPages) {
                var searchOptions = {skip: currentPage, limit: limit};

                if($scope.assessment_filter) {
                    searchOptions.assessments = $scope.assessment_filter;
                }

                rgiDocumentSrvc.query(searchOptions, function (response) {
                    if(response.reason) {
                        rgiNotifier.error('Documents loading failure');
                    } else {
                        $scope.documents = _.union($scope.documents, response.data);
                        currentPage = currentPage + 1;
                        $scope.busy = false;
                    }
                }, rgiHttpResponseProcessorSrvc.getDefaultHandler('Load document data failure'));
            }
        };

        $scope.deleteDocument = function(doc) {
            rgiDialogFactory.deleteDocument($scope, doc);
        };
    });
<commit_msg>SAVEPOINT<commit_after>'use strict';

angular.module('app')
    .controller('rgiDocumentTableCtrl', function (
        _,
        $scope,
        $rootScope,
        rgiDialogFactory,
        rgiAssessmentSrvc,
        rgiDocumentSrvc,
        rgiHttpResponseProcessorSrvc,
        rgiIdentitySrvc,
        rgiNotifier
    ) {
        var limit = 100,
            currentPage = 0,
            totalPages = 0;

        $scope.current_user = rgiIdentitySrvc.currentUser;
        $scope.busy = false;

        $scope.assessment_filter_options = [
            {value: 'all', text: 'Show all documents'}
            // {value: 'type', text: 'Sort by document type'},
            // {value: 'assessments', text: 'Sort by attached assessments'}
        ];

        $scope.assessment_filter = $scope.assessment_filter_options[0].value;

        rgiAssessmentSrvc.query({}, function (assessments) {
            if(assessments.reason) {
                rgiNotifier.error('No assessments');
            } else {
                assessments.forEach(function(assessment) {
                    console.log(assessment);
                    $scope.assessment_filter_options.push({
                        value: assessment.assessment_ID,
                        text: assessment.country + ' ' + assessment.year + ' ' + assessment.version
                    });
                });
            }
        });

        rgiDocumentSrvc.query({skip: currentPage, limit: limit}, function (response) {
            if(response.reason) {
                rgiNotifier.error('Load document data failure');
            } else {
                $scope.count = response.count;
                $scope.documents = response.data;
                totalPages = Math.ceil(response.count / limit);
                currentPage = currentPage + 1;
            }
        }, rgiHttpResponseProcessorSrvc.getDefaultHandler('Load document data failure'));

        $scope.loadMoreDocs = function() {
            if ($scope.busy) {
                return;
            }

            $scope.busy = true;

            if(currentPage < totalPages) {
                rgiDocumentSrvc.query({skip: currentPage, limit: limit}, function (response) {
                    if(response.reason) {
                        rgiNotifier.error('Documents loading failure');
                    } else {
                        $scope.documents = _.union($scope.documents, response.data);
                        currentPage = currentPage + 1;
                        $scope.busy = false;
                    }
                }, rgiHttpResponseProcessorSrvc.getDefaultHandler('Load document data failure'));
            }
        };

        $scope.deleteDocument = function(doc) {
            rgiDialogFactory.deleteDocument($scope, doc);
        };
    });
<|endoftext|>


<commit_before>// TODO: Can we do some inversion of control here?
// TODO: Should we be explicit in export options? -- I think so -- it is good observer formatting
var path = require('path'),
    spawn = require('child_process').spawn,
    Tempfile = require('temporary/lib/file'),
    which = require('which'),
    phantomLocation = which.sync('phantomjs'),
    exporters = {};

// Function to add new exporters
function addExporter(name, exporter) {
  exporters[name] = exporter;
}

// Helper to create exporters (could be a class for better abstraction)
function getPhantomjsExporter(ext) {
  /**
   * Generic exporter
   * @param {Object} options Options to export with
   * @param {Number} [options.quality] Quality of the exported item
   * @param {Function} cb Error-first callback to return binary image string to
   */
  return function phantomjsExporterFn (options, cb) {
    var canvas = this.canvas,
        that = this;

    // Convert over all image paths to url paths
    var images = that.images;
    images.forEach(function getUrlPath (img) {
      img = img.img;
      img._urlpath = path.relative(__dirname + '/scripts', img._filepath);
    });

    // Collect our parameters
    var params = that.params;
    params.images = images;
    params.options = options;

    // Stringify our argument for phantomjs
    var arg = JSON.stringify(params),
        encodedArg = encodeURIComponent(arg);

    // Write out argument to temporary file -- streams weren't cutting it
    var tmp = new Tempfile(),
        filepath = tmp.path;
    tmp.writeFileSync(encodedArg, 'utf8');

    // Create a child process for phantomjs
    var phantomjs = spawn(phantomLocation, [__dirname + '/scripts/compose.js', filepath]);

    // When there is data, save it
    var retVal = '';
    phantomjs.stdout.on('data', function (buffer) {
      // Interpret the buffer into a string, parse it via base64, and into binary
      var str = buffer.toString(),
          base64Buffer = new Buffer(str, 'base64'),
          binaryStr = base64Buffer.toString('binary');

      // Save the binary chunk
      retVal += binaryStr;
    });

    // When there is an error, concatenate it
    var err = '';
    phantomjs.stderr.on('data', function (buffer) {
      err += buffer;
    });

    // When we are done
    phantomjs.on('close', function () {
      // Destroy the temporary file
      try { tmp.unlinkSync(); } catch (e) {}

      // If there was an error in phantom, callback with it
      if (err) {
        cb(new Error(err));
      }

      // Otherwise, callback with our retVal
      cb(null, retVal);
    });
  };
}

// Generate the png exporter
var phantomjsPngExporter = getPhantomjsExporter('png');
addExporter('png', phantomjsPngExporter);
addExporter('image/png', phantomjsPngExporter);

// TODO: It seems we can export jpg and webp images
// https://developer.mozilla.org/en-US/docs/DOM/HTMLCanvasElement#Methods

// Export our exporters
module.exports = {
  exporters: exporters,
  addExporter: addExporter
};<commit_msg>Ignoring buffer lines for userSpaceScaleFactor. Fixes #33<commit_after>// TODO: Can we do some inversion of control here?
// TODO: Should we be explicit in export options? -- I think so -- it is good observer formatting
var path = require('path'),
    spawn = require('child_process').spawn,
    Tempfile = require('temporary/lib/file'),
    which = require('which'),
    phantomLocation = which.sync('phantomjs'),
    exporters = {};

// Function to add new exporters
function addExporter(name, exporter) {
  exporters[name] = exporter;
}

// Helper to create exporters (could be a class for better abstraction)
function getPhantomjsExporter(ext) {
  /**
   * Generic exporter
   * @param {Object} options Options to export with
   * @param {Number} [options.quality] Quality of the exported item
   * @param {Function} cb Error-first callback to return binary image string to
   */
  return function phantomjsExporterFn (options, cb) {
    var canvas = this.canvas,
        that = this;

    // Convert over all image paths to url paths
    var images = that.images;
    images.forEach(function getUrlPath (img) {
      img = img.img;
      img._urlpath = path.relative(__dirname + '/scripts', img._filepath);
    });

    // Collect our parameters
    var params = that.params;
    params.images = images;
    params.options = options;

    // Stringify our argument for phantomjs
    var arg = JSON.stringify(params),
        encodedArg = encodeURIComponent(arg);

    // Write out argument to temporary file -- streams weren't cutting it
    var tmp = new Tempfile(),
        filepath = tmp.path;
    tmp.writeFileSync(encodedArg, 'utf8');

    // Create a child process for phantomjs
    var phantomjs = spawn(phantomLocation, [__dirname + '/scripts/compose.js', filepath]);

    // When there is data, save it
    var retVal = '';
    phantomjs.stdout.on('data', function (buffer) {
      // Interpret the buffer into a string, parse it via base64, and into binary
      var str = buffer.toString(),
          base64Buffer = new Buffer(str, 'base64'),
          binaryStr = base64Buffer.toString('binary');

      // Save the binary chunk
      retVal += binaryStr;
    });

    // When there is an error, concatenate it
    var err = '';
    phantomjs.stderr.on('data', function (buffer) {
      // Ignore PhantomJS 1.9.2 OSX errors
      // https://github.com/Ensighten/grunt-spritesmith/issues/33
      var bufferStr = buffer + '';
      if (bufferStr.indexOf('WARNING: Method userSpaceScaleFactor') === -1) {
        err += bufferStr;
      }
    });

    // When we are done
    phantomjs.on('close', function () {
      // Destroy the temporary file
      try { tmp.unlinkSync(); } catch (e) {}

      // If there was an error in phantom, callback with it
      if (err) {
        cb(new Error(err));
      }

      // Otherwise, callback with our retVal
      cb(null, retVal);
    });
  };
}

// Generate the png exporter
var phantomjsPngExporter = getPhantomjsExporter('png');
addExporter('png', phantomjsPngExporter);
addExporter('image/png', phantomjsPngExporter);

// TODO: It seems we can export jpg and webp images
// https://developer.mozilla.org/en-US/docs/DOM/HTMLCanvasElement#Methods

// Export our exporters
module.exports = {
  exporters: exporters,
  addExporter: addExporter
};<|endoftext|>


<commit_before>module.exports = {
  AED: {
    thickness: 0x0c,
    lengths: {
      5: [0x99, 0x85],
      10: [0x9d, 0x89],
      20: [0x9f, 0x8b],
      50: [0xa1, 0x8d],
      100: [0xa5, 0x91],
      200: [0xa7, 0x93],
      500: [0xa9, 0x95],
      1000: [0xad, 0x99]
    },
    polymer: false
  },
  ANG: {
    thickness: 0x0c,
    lengths: {
      10: [0x98, 0x8e],
      25: [0x98, 0x8e],
      50: [0x98, 0x8e],
      100: [0x98, 0x8e]
    },
    polymer: false
  },
  AUD: {
    thickness: 0x0d,
    lengths: {
      5: [0x8c, 0x78],
      10: [0x93, 0x7f],
      20: [0x9a, 0x86],
      50: [0xa1, 0x8d],
      100: [0xa8, 0x94]
    },
    polymer: true
  },
  BGN: {
    thickness: 0x0d,
    lengths: {
      1: [0x75, 0x6B],
      2: [0x79, 0x6F],
      5: [0x7E, 0x74],
      10: [0x83, 0x79],
      20: [0x88, 0x7E],
      50: [0x8D, 0x83],
      100: [0x92, 0x88]
    },
    polymer: false
  },
  CAD: {
    thickness: 0x0d,
    lengths: {
      5: [0xa2, 0x8e],
      10: [0xa2, 0x8e],
      20: [0xa2, 0x8e],
      50: [0xa2, 0x8e],
      100: [0xa2, 0x8e]
    },
    polymer: true
  },
  CHF: {
    thickness: 0x0d,
    lengths: {
      10: [0x85, 0x71],
      20: [0x8c, 0x78],
      50: [0x93, 0x7f],
      100: [0x9a, 0x86],
      200: [0xa1, 0x8d],
      1000: [0xa8, 0x94]
    },
    polymer: false
  },
  CNY: {
    thickness: 0x0d,
    lengths: {
      1: [0x8c, 0x78],
      5: [0x91, 0x7d],
      10: [0x96, 0x82],
      20: [0x9b, 0x87],
      50: [0xa0, 0x8c],
      100: [0x91, 0xa5]
    },
    polymer: false
  },
  COP: {
    thickness: 0x0d,
    lengths: {
      2000: [0x8a, 0x76],
      5000: [0x8f, 0x7b],
      10000: [0x94, 0x80],
      20000: [0x99, 0x85],
      50000: [0x9e, 0x8a],
      100000: [0xa3, 0x8f]
    },
    polymer: false
  },
  CZK: {
    thickness: 0x0c,
    lengths: {
      100: [0x96, 0x82],
      200: [0x9c, 0x88],
      500: [0xa2, 0x8e],
      1000: [0xa8, 0x94],
      2000: [0xae, 0x9a],
      5000: [0xb4, 0xa0]
    },
    polymer: false
  },
  EUR: {
    thickness: 0x0c,
    lengths: {
      5: [0x82, 0x6e],
      10: [0x89, 0x75],
      20: [0x8f, 0x7b],
      50: [0x96, 0x82],
      100: [0x9d, 0x89],
      200: [0xa3, 0x8f],
      500: [0xaa, 0x96]
    },
    polymer: false
  },
  GBP: {
    thickness: 0x0d,
    lengths: {
      5: [0x91, 0x7d],
      10: [0x98, 0x84],
      20: [0x95, 0x81],
      50: [0xa6, 0x92]
    },
    polymer: true
  },
  GHS: {
    thickness: 0x0c,
    lengths: {
      1: [0x93, 0x7f],
      2: [0x96, 0x82],
      5: [0x97, 0x83],
      10: [0x9b, 0x87],
      20: [0x9f, 0x8b],
      50: [0xa3, 0x8f]
    },
    polymer: false
  },
  GIP: {
    thickness: 0x0c,
    lengths: {
      5: [0x8a, 0x80],
      10: [0x92, 0x88],
      20: [0x9b, 0x91],
      50: [0xa2, 0x98],
      100: [0xa9, 0x9f]
    },
    polymer: false
  },
  GTQ: {
    thickness: 0x0c,
    lengths: {
      1: [0xa0, 0x96],
      5: [0xa0, 0x96],
      10: [0xa0, 0x96],
      20: [0xa0, 0x96],
      50: [0xa0, 0x96],
      100: [0xa1, 0x97],
      200: [0xa0, 0x96]
    },
    polymer: true
  },
  HKD: {
    thickness: 0x0d,
    lengths: {
      10: [0x90, 0x7c],
      20: [0x99, 0x85],
      50: [0x9e, 0x8a],
      100: [0xa3, 0x8f],
      500: [0xa8, 0x94],
      1000: [0xae, 0x9a]
    },
    polymer: false
  },
  HNL: {
    thickness: 0x0c,
    lengths: {
      1: [0xa6, 0x92],
      2: [0xa6, 0x92],
      5: [0xa6, 0x92],
      10: [0xa6, 0x92],
      20: [0xa6, 0x92],
      50: [0xa6, 0x92],
      100: [0xa6, 0x92],
      200: [0xa6, 0x92],
      500: [0xa6, 0x92]
    },
    polymer: false
  },
  HRK: {
    thickness: 0x0c,
    lengths: {
      5: [0x7f, 0x75],
      10: [0x83, 0x79],
      20: [0x87, 0x7d],
      50: [0x8b, 0x81],
      100: [0x8f, 0x85],
      200: [0x93, 0x89],
      500: [0x97, 0x8d],
      1000: [0x9b, 0x91]
    },
    polymer: false
  },
  ILS: {
    thickness: 0x0d,
    lengths: {
      20: [0x8b, 0x77],
      50: [0x92, 0x7e],
      100: [0x99, 0x85],
      200: [0xa0, 0x8c]
    },
    polymer: false
  },
  JPY: {
    thickness: 0x0d,
    lengths: {
      1000: [0x99, 0x93],
      2000: [0x9c, 0x98],
      5000: [0x9d, 0x9a],
      10000: [0xa3, 0x9e]
    },
    polymer: false
  },
  KRW: {
    thickness: 0x0d,
    lengths: {
      1000: [0x92, 0x7e],
      2000: [0x96, 0x82],
      5000: [0x98, 0x84],
      10000: [0x9e, 0x8a],
      50000: [0xa4, 0x90]
    },
    polymer: false
  },
  MDL: {
    thickness: 0x0c,
    lengths: {
      1: [0x7c, 0x6e],
      5: [0x7c, 0x6e],
      10: [0x83, 0x6f],
      20: [0x83, 0x6f],
      50: [0x83, 0x6f],
      100: [0x83, 0x6f],
      200: [0x8f, 0x7b],
      500: [0x8f, 0x7b],
      1000: [0x8f, 0x7b]
    },
    polymer: false
  },
  MXN: {
    thickness: 0x0c,
    lengths: {
      20: [0x7d, 0x73],
      50: [0x82, 0x78],
      100: [0x89, 0x7f],
      200: [0x90, 0x86],
      500: [0x97, 0x8d],
      1000: [0x9e, 0x94]
    },
    polymer: true
  },
  MYR: {
    thickness: 0x0c,
    lengths: {
      1: [0x82, 0x6e],
      5: [0x91, 0x7d],
      10: [0x96, 0x82],
      20: [0x9b, 0x87],
      50: [0x9b, 0x87],
      100: [0xa0, 0x8c]
    },
    polymer: false
  },
  NZD: {
    thickness: 0x0c,
    lengths: {
      5:  [0x8c, 0x82],
      10: [0x91, 0x87],
      20: [0x96, 0x8c],
      50: [0x9b, 0x91],
      100: [0xa0, 0x96],
    },
    polymer: true
  },
  PHP: {
    thickness: 0x0c,
    lengths: {
      20: [0xaa, 0x96],
      100: [0xaa, 0x96],
      200: [0xaa, 0x96],
      500: [0xaa, 0x96],
      1000: [0xaa, 0x96]
    },
    polymer: false
  },
   PLN: {
    thickness: 0x0c,
    lengths: {
      10: [0x7d, 0x73],
      20: [0x83, 0x79],
      50: [0x89, 0x7f],
      100: [0x8f, 0x85],
      200: [0x95, 0x8b],
      500: [0x9b, 0x91]
    },
    polymer: false
  },
  RON: {
    thickness: 0x0c,
    lengths: {
      1: [0x82, 0x6e],
      5: [0x89, 0x75],
      10: [0x8f, 0x7b],
      50: [0x96, 0x82],
      100: [0x9d, 0x89],
      200: [0xa0, 0x8c],
      500: [0xa3, 0x8f]
    },
    polymer: true
  },
  SGD: {
    thickness: 0x0c,
    lengths: {
      2: [0x88, 0x74],
      5: [0x8f, 0x7b],
      10: [0x97, 0x83],
      50: [0xa6, 0x92],
      100: [0xac, 0x98],
      1000: [0xb4, 0xa0]
    },
    polymer: false
  },
  TWD: {
    thickness: 0x0d,
    lengths: {
      100: [0x9b, 0x87],
      200: [0xa0, 0x8c],
      500: [0xa5, 0x91],
      1000: [0xaa, 0x96],
      2000: [0xaf, 0x9b]
    },
    polymer: false
  },
  USD: {
    thickness: 0x0d,
    lengths: {
      1: [0xa6, 0x92],
      2: [0xa6, 0x92],
      5: [0xa6, 0x92],
      10: [0xa6, 0x92],
      20: [0xa6, 0x92],
      50: [0xa6, 0x92],
      100: [0xa6, 0x92]
    },
    polymer: false
  },
  ZAR: {
    thickness: 0x0c,
    lengths: {
      10: [0x8a, 0x76],
      20: [0x90, 0x7c],
      50: [0x96, 0x82],
      100: [0x9c, 0x88],
      200: [0xa2, 0x8e]
    },
    polymer: false
  }
}
<commit_msg>fix: extraneous space and comma<commit_after>module.exports = {
  AED: {
    thickness: 0x0c,
    lengths: {
      5: [0x99, 0x85],
      10: [0x9d, 0x89],
      20: [0x9f, 0x8b],
      50: [0xa1, 0x8d],
      100: [0xa5, 0x91],
      200: [0xa7, 0x93],
      500: [0xa9, 0x95],
      1000: [0xad, 0x99]
    },
    polymer: false
  },
  ANG: {
    thickness: 0x0c,
    lengths: {
      10: [0x98, 0x8e],
      25: [0x98, 0x8e],
      50: [0x98, 0x8e],
      100: [0x98, 0x8e]
    },
    polymer: false
  },
  AUD: {
    thickness: 0x0d,
    lengths: {
      5: [0x8c, 0x78],
      10: [0x93, 0x7f],
      20: [0x9a, 0x86],
      50: [0xa1, 0x8d],
      100: [0xa8, 0x94]
    },
    polymer: true
  },
  BGN: {
    thickness: 0x0d,
    lengths: {
      1: [0x75, 0x6B],
      2: [0x79, 0x6F],
      5: [0x7E, 0x74],
      10: [0x83, 0x79],
      20: [0x88, 0x7E],
      50: [0x8D, 0x83],
      100: [0x92, 0x88]
    },
    polymer: false
  },
  CAD: {
    thickness: 0x0d,
    lengths: {
      5: [0xa2, 0x8e],
      10: [0xa2, 0x8e],
      20: [0xa2, 0x8e],
      50: [0xa2, 0x8e],
      100: [0xa2, 0x8e]
    },
    polymer: true
  },
  CHF: {
    thickness: 0x0d,
    lengths: {
      10: [0x85, 0x71],
      20: [0x8c, 0x78],
      50: [0x93, 0x7f],
      100: [0x9a, 0x86],
      200: [0xa1, 0x8d],
      1000: [0xa8, 0x94]
    },
    polymer: false
  },
  CNY: {
    thickness: 0x0d,
    lengths: {
      1: [0x8c, 0x78],
      5: [0x91, 0x7d],
      10: [0x96, 0x82],
      20: [0x9b, 0x87],
      50: [0xa0, 0x8c],
      100: [0x91, 0xa5]
    },
    polymer: false
  },
  COP: {
    thickness: 0x0d,
    lengths: {
      2000: [0x8a, 0x76],
      5000: [0x8f, 0x7b],
      10000: [0x94, 0x80],
      20000: [0x99, 0x85],
      50000: [0x9e, 0x8a],
      100000: [0xa3, 0x8f]
    },
    polymer: false
  },
  CZK: {
    thickness: 0x0c,
    lengths: {
      100: [0x96, 0x82],
      200: [0x9c, 0x88],
      500: [0xa2, 0x8e],
      1000: [0xa8, 0x94],
      2000: [0xae, 0x9a],
      5000: [0xb4, 0xa0]
    },
    polymer: false
  },
  EUR: {
    thickness: 0x0c,
    lengths: {
      5: [0x82, 0x6e],
      10: [0x89, 0x75],
      20: [0x8f, 0x7b],
      50: [0x96, 0x82],
      100: [0x9d, 0x89],
      200: [0xa3, 0x8f],
      500: [0xaa, 0x96]
    },
    polymer: false
  },
  GBP: {
    thickness: 0x0d,
    lengths: {
      5: [0x91, 0x7d],
      10: [0x98, 0x84],
      20: [0x95, 0x81],
      50: [0xa6, 0x92]
    },
    polymer: true
  },
  GHS: {
    thickness: 0x0c,
    lengths: {
      1: [0x93, 0x7f],
      2: [0x96, 0x82],
      5: [0x97, 0x83],
      10: [0x9b, 0x87],
      20: [0x9f, 0x8b],
      50: [0xa3, 0x8f]
    },
    polymer: false
  },
  GIP: {
    thickness: 0x0c,
    lengths: {
      5: [0x8a, 0x80],
      10: [0x92, 0x88],
      20: [0x9b, 0x91],
      50: [0xa2, 0x98],
      100: [0xa9, 0x9f]
    },
    polymer: false
  },
  GTQ: {
    thickness: 0x0c,
    lengths: {
      1: [0xa0, 0x96],
      5: [0xa0, 0x96],
      10: [0xa0, 0x96],
      20: [0xa0, 0x96],
      50: [0xa0, 0x96],
      100: [0xa1, 0x97],
      200: [0xa0, 0x96]
    },
    polymer: true
  },
  HKD: {
    thickness: 0x0d,
    lengths: {
      10: [0x90, 0x7c],
      20: [0x99, 0x85],
      50: [0x9e, 0x8a],
      100: [0xa3, 0x8f],
      500: [0xa8, 0x94],
      1000: [0xae, 0x9a]
    },
    polymer: false
  },
  HNL: {
    thickness: 0x0c,
    lengths: {
      1: [0xa6, 0x92],
      2: [0xa6, 0x92],
      5: [0xa6, 0x92],
      10: [0xa6, 0x92],
      20: [0xa6, 0x92],
      50: [0xa6, 0x92],
      100: [0xa6, 0x92],
      200: [0xa6, 0x92],
      500: [0xa6, 0x92]
    },
    polymer: false
  },
  HRK: {
    thickness: 0x0c,
    lengths: {
      5: [0x7f, 0x75],
      10: [0x83, 0x79],
      20: [0x87, 0x7d],
      50: [0x8b, 0x81],
      100: [0x8f, 0x85],
      200: [0x93, 0x89],
      500: [0x97, 0x8d],
      1000: [0x9b, 0x91]
    },
    polymer: false
  },
  ILS: {
    thickness: 0x0d,
    lengths: {
      20: [0x8b, 0x77],
      50: [0x92, 0x7e],
      100: [0x99, 0x85],
      200: [0xa0, 0x8c]
    },
    polymer: false
  },
  JPY: {
    thickness: 0x0d,
    lengths: {
      1000: [0x99, 0x93],
      2000: [0x9c, 0x98],
      5000: [0x9d, 0x9a],
      10000: [0xa3, 0x9e]
    },
    polymer: false
  },
  KRW: {
    thickness: 0x0d,
    lengths: {
      1000: [0x92, 0x7e],
      2000: [0x96, 0x82],
      5000: [0x98, 0x84],
      10000: [0x9e, 0x8a],
      50000: [0xa4, 0x90]
    },
    polymer: false
  },
  MDL: {
    thickness: 0x0c,
    lengths: {
      1: [0x7c, 0x6e],
      5: [0x7c, 0x6e],
      10: [0x83, 0x6f],
      20: [0x83, 0x6f],
      50: [0x83, 0x6f],
      100: [0x83, 0x6f],
      200: [0x8f, 0x7b],
      500: [0x8f, 0x7b],
      1000: [0x8f, 0x7b]
    },
    polymer: false
  },
  MXN: {
    thickness: 0x0c,
    lengths: {
      20: [0x7d, 0x73],
      50: [0x82, 0x78],
      100: [0x89, 0x7f],
      200: [0x90, 0x86],
      500: [0x97, 0x8d],
      1000: [0x9e, 0x94]
    },
    polymer: true
  },
  MYR: {
    thickness: 0x0c,
    lengths: {
      1: [0x82, 0x6e],
      5: [0x91, 0x7d],
      10: [0x96, 0x82],
      20: [0x9b, 0x87],
      50: [0x9b, 0x87],
      100: [0xa0, 0x8c]
    },
    polymer: false
  },
  NZD: {
    thickness: 0x0c,
    lengths: {
      5: [0x8c, 0x82],
      10: [0x91, 0x87],
      20: [0x96, 0x8c],
      50: [0x9b, 0x91],
      100: [0xa0, 0x96]
    },
    polymer: true
  },
  PHP: {
    thickness: 0x0c,
    lengths: {
      20: [0xaa, 0x96],
      100: [0xaa, 0x96],
      200: [0xaa, 0x96],
      500: [0xaa, 0x96],
      1000: [0xaa, 0x96]
    },
    polymer: false
  },
   PLN: {
    thickness: 0x0c,
    lengths: {
      10: [0x7d, 0x73],
      20: [0x83, 0x79],
      50: [0x89, 0x7f],
      100: [0x8f, 0x85],
      200: [0x95, 0x8b],
      500: [0x9b, 0x91]
    },
    polymer: false
  },
  RON: {
    thickness: 0x0c,
    lengths: {
      1: [0x82, 0x6e],
      5: [0x89, 0x75],
      10: [0x8f, 0x7b],
      50: [0x96, 0x82],
      100: [0x9d, 0x89],
      200: [0xa0, 0x8c],
      500: [0xa3, 0x8f]
    },
    polymer: true
  },
  SGD: {
    thickness: 0x0c,
    lengths: {
      2: [0x88, 0x74],
      5: [0x8f, 0x7b],
      10: [0x97, 0x83],
      50: [0xa6, 0x92],
      100: [0xac, 0x98],
      1000: [0xb4, 0xa0]
    },
    polymer: false
  },
  TWD: {
    thickness: 0x0d,
    lengths: {
      100: [0x9b, 0x87],
      200: [0xa0, 0x8c],
      500: [0xa5, 0x91],
      1000: [0xaa, 0x96],
      2000: [0xaf, 0x9b]
    },
    polymer: false
  },
  USD: {
    thickness: 0x0d,
    lengths: {
      1: [0xa6, 0x92],
      2: [0xa6, 0x92],
      5: [0xa6, 0x92],
      10: [0xa6, 0x92],
      20: [0xa6, 0x92],
      50: [0xa6, 0x92],
      100: [0xa6, 0x92]
    },
    polymer: false
  },
  ZAR: {
    thickness: 0x0c,
    lengths: {
      10: [0x8a, 0x76],
      20: [0x90, 0x7c],
      50: [0x96, 0x82],
      100: [0x9c, 0x88],
      200: [0xa2, 0x8e]
    },
    polymer: false
  }
}
<|endoftext|>