tounit.js 668 B

123456789101112131415161718192021222324252627
  1. /**
  2. * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /**
  6. * @module utils/dom/tounit
  7. */
  8. /**
  9. * Returns a helper function, which adds a desired trailing
  10. * `unit` to the passed value.
  11. *
  12. * @param {String} unit An unit like "px" or "em".
  13. * @returns {module:utils/dom/tounit~helper}
  14. */
  15. export default function toUnit( unit ) {
  16. /**
  17. * A function, which adds a pre–defined trailing `unit`
  18. * to the passed `value`.
  19. *
  20. * @function helper
  21. * @param {*} value A value to be given the unit.
  22. * @returns {String} A value with the trailing unit.
  23. */
  24. return value => value + unit;
  25. }