a zip code crypto-currency system good for red ONLY

getPaths.js 967B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. module.exports = function getPaths(path) {
  6. var parts = path.split(/(.*?[\\\/]+)/);
  7. var paths = [path];
  8. var seqments = [parts[parts.length - 1]];
  9. var part = parts[parts.length - 1];
  10. path = path.substr(0, path.length - part.length - 1);
  11. paths.push(path);
  12. for(var i = parts.length - 2; i > 2; i -= 2) {
  13. part = parts[i];
  14. path = path.substr(0, path.length - part.length) || "/";
  15. paths.push(path);
  16. seqments.push(part.substr(0, part.length - 1));
  17. }
  18. part = parts[1];
  19. seqments.push(part.length > 1 ? part.substr(0, part.length - 1) : part);
  20. return {
  21. paths: paths,
  22. seqments: seqments
  23. };
  24. };
  25. module.exports.basename = function basename(path) {
  26. var i = path.lastIndexOf("/"),
  27. j = path.lastIndexOf("\\");
  28. var p = i < 0 ? j : j < 0 ? i : i < j ? j : i;
  29. if(p < 0) return null;
  30. var s = path.substr(p + 1);
  31. return s;
  32. };