@jdeighan/coffee-utils 4.0.17 → 4.0.18

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jdeighan/coffee-utils",
3
3
  "type": "module",
4
- "version": "4.0.17",
4
+ "version": "4.0.18",
5
5
  "description": "A set of utility functions for CoffeeScript",
6
6
  "main": "coffee_utils.js",
7
7
  "exports": {
@@ -30,6 +30,15 @@ export isSimpleFileName = (path) ->
30
30
  h = pathlib.parse(path)
31
31
  return ! h.root && ! h.dir && h.base
32
32
 
33
+ # ---------------------------------------------------------------------------
34
+
35
+ export fileExt = (path) ->
36
+
37
+ if lMatches = path.match(/\.[A-Za-z0-9_]+$/)
38
+ return lMatches[0]
39
+ else
40
+ return ''
41
+
33
42
  # ---------------------------------------------------------------------------
34
43
  # mydir() - pass argument `import.meta.url` and it will return
35
44
  # the directory your file is in
package/src/fs_utils.js CHANGED
@@ -45,6 +45,16 @@ export var isSimpleFileName = function(path) {
45
45
  return !h.root && !h.dir && h.base;
46
46
  };
47
47
 
48
+ // ---------------------------------------------------------------------------
49
+ export var fileExt = function(path) {
50
+ var lMatches;
51
+ if (lMatches = path.match(/\.[A-Za-z0-9_]+$/)) {
52
+ return lMatches[0];
53
+ } else {
54
+ return '';
55
+ }
56
+ };
57
+
48
58
  // ---------------------------------------------------------------------------
49
59
  // mydir() - pass argument `import.meta.url` and it will return
50
60
  // the directory your file is in