optionsFromStrings.js 730 B

123456789101112131415161718192021222324252627
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = optionsFromStrings;
  6. // Convert string to integers/booleans where it should be
  7. function optionsFromStrings(options) {
  8. var intOptions = ["width", "height", "textMargin", "fontSize", "margin", "marginTop", "marginBottom", "marginLeft", "marginRight"];
  9. for (var intOption in intOptions) {
  10. if (intOptions.hasOwnProperty(intOption)) {
  11. intOption = intOptions[intOption];
  12. if (typeof options[intOption] === "string") {
  13. options[intOption] = parseInt(options[intOption], 10);
  14. }
  15. }
  16. }
  17. if (typeof options["displayValue"] === "string") {
  18. options["displayValue"] = options["displayValue"] != "false";
  19. }
  20. return options;
  21. }