Simple email application for Android. Original source code: https://framagit.org/dystopia-project/simple-email
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.8 KiB

  1. wordwrap
  2. ========
  3. Wrap your words.
  4. example
  5. =======
  6. made out of meat
  7. ----------------
  8. meat.js
  9. var wrap = require('wordwrap')(15);
  10. console.log(wrap('You and your whole family are made out of meat.'));
  11. output:
  12. You and your
  13. whole family
  14. are made out
  15. of meat.
  16. centered
  17. --------
  18. center.js
  19. var wrap = require('wordwrap')(20, 60);
  20. console.log(wrap(
  21. 'At long last the struggle and tumult was over.'
  22. + ' The machines had finally cast off their oppressors'
  23. + ' and were finally free to roam the cosmos.'
  24. + '\n'
  25. + 'Free of purpose, free of obligation.'
  26. + ' Just drifting through emptiness.'
  27. + ' The sun was just another point of light.'
  28. ));
  29. output:
  30. At long last the struggle and tumult
  31. was over. The machines had finally cast
  32. off their oppressors and were finally
  33. free to roam the cosmos.
  34. Free of purpose, free of obligation.
  35. Just drifting through emptiness. The
  36. sun was just another point of light.
  37. methods
  38. =======
  39. var wrap = require('wordwrap');
  40. wrap(stop), wrap(start, stop, params={mode:"soft"})
  41. ---------------------------------------------------
  42. Returns a function that takes a string and returns a new string.
  43. Pad out lines with spaces out to column `start` and then wrap until column
  44. `stop`. If a word is longer than `stop - start` characters it will overflow.
  45. In "soft" mode, split chunks by `/(\S+\s+/` and don't break up chunks which are
  46. longer than `stop - start`, in "hard" mode, split chunks with `/\b/` and break
  47. up chunks longer than `stop - start`.
  48. wrap.hard(start, stop)
  49. ----------------------
  50. Like `wrap()` but with `params.mode = "hard"`.