Utilities

Provides utility functions.

بۇ قوليازمىنى بىۋاسىتە قاچىلاشقا بولمايدۇ. بۇ باشقا قوليازمىلارنىڭ ئىشلىتىشى ئۈچۈن تەمىنلەنگەن ئامبار بولۇپ، ئىشلىتىش ئۈچۈن مېتا كۆرسەتمىسىگە قىستۇرىدىغان كود: // @require https://update.greatest.deepsurf.us/scripts/31227/204776/Utilities.js

  1. /**
  2. * @author Anthony Pizzimenti
  3. * @desc Checks whether a parameter exists and is of the desired type.
  4. * @param {*} param Paramter to check.
  5. * @param {string} type Desired type.
  6. * @returns {boolean}
  7. * @private
  8. */
  9. function _paramExist (param, type) {
  10. return typeof param === type && param !== undefined && param !== null;
  11. }
  12.  
  13. /**
  14. * @author Anthony Pizzimenti
  15. * @desc Creates an absolute URL from the provided path and root.
  16. * @param {string} root Root URL.
  17. * @param {string} path Root-relative path.
  18. * @returns {*}
  19. */
  20. function absurl (root, path) {
  21. if (_paramExist(root, "string") && _paramExist(path, "string")) {
  22. if (root[root.length - 1] === "/") {
  23. return root + path;
  24. } else {
  25. return root + "/" + path;
  26. }
  27. }
  28. return null;
  29. }