Gathering detailed insights and metrics for @jsenv/url-meta
Gathering detailed insights and metrics for @jsenv/url-meta
npm install @jsenv/url-meta
Typescript
Module System
Node Version
NPM Version
73.2
Supply Chain
95.2
Quality
81.8
Maintenance
100
Vulnerability
100
License
JavaScript (76.76%)
HTML (22.7%)
CSS (0.53%)
TypeScript (0.01%)
Total Downloads
141,864
Last Day
10
Last Week
165
Last Month
1,115
Last Year
30,983
31 Stars
11,191 Commits
4 Forks
4 Watching
1 Branches
3 Contributors
Latest Version
8.5.2
Package Id
@jsenv/url-meta@8.5.2
Unpacked Size
18.79 kB
Size
4.99 kB
File Count
5
NPM Version
10.8.1
Node Version
22.3.0
Publised On
20 Aug 2024
Cumulative downloads
Total Downloads
Last day
11.1%
10
Compared to previous day
Last week
-2.9%
165
Compared to previous week
Last month
2.8%
1,115
Compared to previous month
Last year
17.3%
30,983
Compared to previous year
Associate value to urls using pattern matching.
1import { URL_META } from "@jsenv/url-meta"; 2 3// conditionally associates url and values 4const associations = { 5 color: { 6 "file:///*": "black", 7 "file:///*.js": "red", 8 }, 9}; 10const getUrlColor = (url) => { 11 const { color } = URL_META.applyAssociations({ url, associations }); 12 return color; 13}; 14console.log(`file.json color is ${getUrlColor("file:///file.json")}`); 15console.log(`file.js color is ${getUrlColor("file:///file.js")}`);
Code above logs
1file.json color is black 2file.js color is red
pattern | Description |
---|---|
**/ | Everything |
*/**/ | Inside a directory |
**/.*/ | Inside directory starting with a dot |
**/node_modules/ | Inside any node_modules directory |
node_modules/ | Inside root node_modules directory |
**/*.map | Ending with .map |
**/*.test.* | Contains .test. |
* | Inside the root directory only |
*/* | Inside a directory of depth 1 |
Read more at ./pattern_matching.md
associations below translates into: "files are visible except thoose in .git/ directory"
1const associations = { 2 visible: { 3 "**/*/": true, 4 "**/.git/": false, 5 }, 6};
associations allows to group patterns per property which are easy to read and compose. All keys in associations must be absolute urls, this can be done with resolveAssociations.
resolveAssociations is a function resolving associations keys that may contain relative urls against an url.
1import { URL_META } from "@jsenv/url-meta"; 2 3const associations = URL_META.resolveAssociations( 4 { 5 visible: { 6 "**/*/": true, 7 "**/.git/": false, 8 }, 9 }, 10 "file:///Users/directory/", 11); 12console.log(JSON.stringify(associations, null, " "));
1{ 2 "visible": { 3 "file:///Users/directory/**/*/": true, 4 "file:///Users/directory/**/.git/": false 5 } 6}
No vulnerabilities found.
No security vulnerabilities found.