Guest User

Untitled

a guest
Nov 21st, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. function (str, noclobber) {
  2. var i, a = str.split("."),
  3. o = window,
  4. callthrough = false;
  5. if (/[^a-zA-Z.]/.test(str)) {
  6. //-debug start
  7. console.error("@namepace: not a valid namespace identifier");
  8. //-debug end
  9. return false;
  10. }
  11. for (i = 0; i < a.length; i++) {
  12. if (!o[a[i]]) {
  13.  
  14. o[a[i]] = {};
  15. callthrough = true;
  16. }
  17. o = o[a[i]];
  18. }
  19. if ( !! noclobber) {
  20. return callthrough;
  21. }
  22.  
  23. return true;
  24. }
Add Comment
Please, Sign In to add comment