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.

25 lines
684 B

  1. // transform /path/to/file.ext to file.ext
  2. export function basename(path = '') {
  3. return path ? path.replace(/^.*\//, '') : '';
  4. }
  5. // transform /path/to/file.ext to .ext
  6. export function extname(path = '') {
  7. const [_, ext] = /.+(\.[^.]+)$/.exec(path) || [];
  8. return ext || '';
  9. }
  10. // test whether a variable is an object
  11. export function isObject(obj) {
  12. return Object.prototype.toString.call(obj) === '[object Object]';
  13. }
  14. // returns whether a dark theme is enabled
  15. export function isDarkTheme() {
  16. return document.documentElement.classList.contains('theme-arc-green');
  17. }
  18. // removes duplicate elements in an array
  19. export function uniq(arr) {
  20. return Array.from(new Set(arr));
  21. }