Socket
Socket
Sign inDemoInstall

@jsenv/url-meta

Package Overview
Dependencies
Maintainers
2
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jsenv/url-meta - npm Package Compare versions

Comparing version 6.0.0 to 6.0.1

dist/commonjs/jsenv_url_meta.cjs

63

package.json
{
"name": "@jsenv/url-meta",
"version": "6.0.0",
"description": "Associate data to urls using patterns.",
"version": "6.0.1",
"description": "Associate data to urls using patterns",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/jsenv/jsenv-url-meta"
"url": "https://github.com/jsenv/url-meta"
},
"publishConfig": {
"access": "public"
"access": "public",
"registry": "https://registry.npmjs.org"
},
"engines": {
"node": ">=12.0.0"
"node": ">=14.12.0"
},

@@ -20,6 +21,6 @@ "type": "module",

"import": "./index.js",
"require": "./dist/commonjs/main.cjs"
}
"require": "./dist/commonjs/jsenv_url_meta.cjs"
},
"./*": "./*"
},
"main": "dist/commonjs/main.cjs",
"files": [

@@ -31,33 +32,33 @@ "/dist/",

"scripts": {
"start-exploring": "node ./script/start-exploring/start-exploring.js",
"test": "node --unhandled-rejections=strict ./script/test/test.js",
"start": "node ./script/start/start_exploring.mjs",
"eslint-check": "node ./node_modules/eslint/bin/eslint.js . --ext=.html,.js,.mjs,.cjs",
"generate-importmap": "node ./script/importmap/generate_importmap.mjs",
"test": "node --unhandled-rejections=strict ./script/test/test.mjs",
"test-with-coverage": "npm run test -- --coverage",
"eslint-check": "node ./node_modules/eslint/bin/eslint.js .",
"prettier-format": "node ./script/prettier-format/prettier-format.js",
"dist": "npm run build-esmodule && npm run build-commonjs",
"build-esmodule": "node ./script/build/build_esmodule.mjs",
"build-commonjs": "node --experimental-import-meta-resolve ./script/build/build_commonjs.mjs",
"prettier-format": "node ./script/prettier/prettier_format.mjs",
"prettier-format-stage": "npm run prettier-format -- --staged",
"prettier-check": "npm run prettier-format -- --dry-run",
"upload-coverage": "node ./script/upload-coverage/upload-coverage.js",
"generate-esmodule-bundle": "node ./script/generate-esmodule-bundle/generate-esmodule-bundle.js",
"generate-commonjs-bundle": "node ./script/generate-commonjs-bundle/generate-commonjs-bundle.js",
"generate-import-map": "node ./script/generate-import-map/generate-import-map.js",
"dist": "npm run generate-esmodule-bundle && npm run generate-commonjs-bundle",
"prepublishOnly": "node ./script/transform-package/remove-postinstall.js && npm run dist",
"postpublish": "node ./script/transform-package/restore-postinstall.js"
"install-playwright": "npx playwright install-deps && npx playwright install",
"prepublishOnly": "node ./script/publish/remove_postinstall.mjs && npm run dist",
"postpublish": "node ./script/publish/restore_postinstall.mjs"
},
"dependencies": {},
"devDependencies": {
"@jsenv/assert": "2.2.1",
"@jsenv/codecov-upload": "3.4.3",
"@jsenv/core": "17.1.7",
"@jsenv/eslint-config": "12.8.0",
"@jsenv/github-release-package": "1.2.2",
"@jsenv/node-module-import-map": "12.2.1",
"@jsenv/package-publish": "1.5.1",
"@jsenv/assert": "2.3.1",
"@jsenv/codecov-upload": "3.5.0",
"@jsenv/core": "19.6.2",
"@jsenv/eslint-config": "15.0.2",
"@jsenv/github-release-package": "1.2.3",
"@jsenv/importmap-eslint-resolver": "5.1.0",
"@jsenv/importmap-node-module": "1.0.1",
"@jsenv/package-publish": "1.6.2",
"@jsenv/prettier-check-project": "5.6.1",
"eslint": "7.15.0",
"playwright-chromium": "1.6.2",
"playwright-firefox": "1.6.2",
"playwright-webkit": "1.6.2",
"prettier": "2.2.1"
"eslint": "7.32.0",
"eslint-plugin-html": "6.1.2",
"eslint-plugin-import": "2.24.0",
"prettier": "2.3.2"
}
}

@@ -5,18 +5,6 @@ # url-meta

[![github package](https://img.shields.io/github/package-json/v/jsenv/jsenv-url-meta.svg?logo=github&label=package)](https://github.com/jsenv/jsenv-url-meta/packages)
[![npm package](https://img.shields.io/npm/v/@jsenv/url-meta.svg?logo=npm&label=package)](https://www.npmjs.com/package/@jsenv/url-meta)
[![github ci](https://github.com/jsenv/jsenv-url-meta/workflows/ci/badge.svg)](https://github.com/jsenv/jsenv-url-meta/actions?workflow=ci)
[![codecov coverage](https://codecov.io/gh/jsenv/jsenv-url-meta/branch/master/graph/badge.svg)](https://codecov.io/gh/jsenv/jsenv-url-meta)
[![github ci](https://github.com/jsenv/url-meta/workflows/main/badge.svg)](https://github.com/jsenv/url-meta/actions?workflow=main)
[![codecov coverage](https://codecov.io/gh/jsenv/url-meta/branch/master/graph/badge.svg)](https://codecov.io/gh/jsenv/url-meta)
## Table of contents
- [Presentation](#Presentation)
- [Installation](#Installation)
- [Terminology](#Terminology)
- [Pattern matching](#pattern-matching)
- [applyPatternMatching](#applyPatternMatching)
- [normalizeStructuredMetaMap](#normalizeStructuredMetaMap)
- [urlCanContainsMetaMatching](#urlCanContainsMetaMatching)
- [urlToMeta](#urlToMeta)
# Presentation

@@ -30,3 +18,3 @@

// conditionally associates url and values
const metaMap = {
const structuredMetaMap = {
color: {

@@ -39,3 +27,3 @@ "file:///*": "black",

const urlToColor = (url) => {
return urlToMeta({ url, metaMap }).color
return urlToMeta({ url, structuredMetaMap }).color
}

@@ -47,3 +35,3 @@

Code above logs
_Code above logs_

@@ -55,123 +43,49 @@ ```console

# Installation
# Common pattern example
```console
npm install @jsenv/url-meta
```
| pattern | Description |
| ------------------ | ------------------------------------ |
| `**/` | Everything |
| `*/**/` | Inside a directory |
| `**/.*/` | Inside directory starting with a dot |
| `**/node_modules/` | Inside `node_modules` directory |
| `**/*.map` | Ending with `.map` |
| `**/*.test.*` | Contains `.test.` |
| `*` | Inside the root directory only |
| `*/*` | Inside a directory of depth 1 |
Can be used in browsers and Node.js.
# Pattern matching example
> Should work with node 12.8+. Other versions are not tested.
Table showing if a pattern matches when applied to `"file:///directory/file.js"`
# Terminology
| pattern | matches? |
| ---------------------------- | -------- |
| `file:///directory/*.js` | true |
| `file:///directory/**/*.js` | true |
| `file:///**/*.js` | true |
| `file:///directory` | false |
| `file:///directory/` | true |
| `file:///directory/file.js` | true |
| `file:///directory/file.jsx` | false |
This part introduces some words used in this codebase and documentation.
# metaMap and structuredMetaMap
## metaMap
_metaMap_ and _structuredMetaMap_ below translates into: "files are visible except thoose in .git/ directory"
A `metaMap` is an object composed by `pattern` and `meta`. A `pattern` is a string like `file:///*.js` and `meta` is an object where you can put what you want.
A `metaMap` object example:
```json
{
"**/*": { "visible": true },
"**/.git": { "visible": false }
}
```
> The object above can be translated into the following sentence: all files are visible except files in `.git` directory.
<details>
<summary>metaMap namings</summary>
> Name of variables in the code below corresponds to terminology used in the codebase and documentation.
```js
const pattern = "**/*"
const meta = { visible: true }
const metaMap = {
[pattern]: meta,
"**/*": { visible: true },
"**/.git/": { visible: false },
}
```
</details>
## structuredMetaMap
A `structuredMetaMap` is an object composed by `metaProperty` and `metaValueMap`. `metaValueMap` are themselves composed by `pattern` and `metaValue`. `structuredMetaMap` is an other way of associating ,meta to urls.
A `structuredMetaMap` example:
```json
{
"visible": {
const structuredMetaMap = {
visible: {
"**/*/": true,
"**/.git/": false
}
"**/.git/": false,
},
}
```
> `structuredMetaMap` format helps to structure the logic. As a consequence, it is the format used by our apis.
_structuredMetaMap_ allows to group patterns per property which are easier to read and compose. For this reason it's the object structure used by our API.
<details>
<summary>structuredMetaMap namings</summary>
> Name of variables in the code below corresponds to terminology used in the codebase and documentation.
```js
const pattern = "**/*/"
const metaProperty = "visible"
const metaValue = true
const metaValueMap = {
[pattern]: metaValue,
}
const structuredMetaMap = {
[metaProperty]: metaValueMap,
}
```
</details>
# Pattern matching
<details>
<summary>Pattern matching example</summary>
Some example of pattern applied to `file:///whatever/file.js`
| pattern | matches |
| --------------------------- | ------- |
| `file:///whatever` | false |
| `file:///whatever/` | true |
| `file:///whatever/*.js` | true |
| `file:///whatever/**/*.js` | true |
| `file:///**/*.js` | true |
| `file:///whatever/file.js` | true |
| `file:///whatever/file.jsx` | false |
</details>
<details>
<summary>Common pattern example</summary>
| pattern | Description |
| ------------------ | ------------------------------------ |
| `**/` | Everything |
| `*/**/` | Inside a directory |
| `**/.*/` | Inside directory starting with a dot |
| `**/node_modules/` | Inside `node_modules` directory |
| `**/*.map` | Ending with `.map` |
| `**/*.test.*` | Contains `test` |
> `**/` and `**/*` are equivalent
More examples that should be rarely used in practice:
| specifier | Description |
| --------- | ----------------------------- |
| `*/*` | Inside a directory of depth 1 |
</details>
# applyPatternMatching

@@ -181,5 +95,2 @@

<details>
<summary>applyPatternMatching code example</summary>
```js

@@ -196,6 +107,2 @@ import { applyPatternMatching } from "@jsenv/url-meta"

— source code at [src/applyPatternMatching.js](./src/applyPatternMatching.js).
</details>
## pattern

@@ -213,5 +120,2 @@

<details>
<summary>matchResult example</summary>
```js

@@ -225,3 +129,3 @@ const fullMatch = applyPatternMatching({

> fullMatch object indicates `pattern` fully matched `url`.
fullMatch object indicates `pattern` fully matched `url`.

@@ -236,6 +140,4 @@ ```js

> partialMatch object indicates `pattern` matched `url` until comparing `url[14]` with `pattern[14]`.
partialMatch object indicates `pattern` matched `url` until comparing `url[14]` with `pattern[14]`.
</details>
# normalizeStructuredMetaMap

@@ -245,5 +147,2 @@

<details>
<summary>normalizeStructuredMetaMap code example</summary>
```js

@@ -273,6 +172,2 @@ import { normalizeStructuredMetaMap } from "@jsenv/url-meta"

— source code at [src/normalizeStructuredMetaMap.js](./src/normalizeStructuredMetaMap.js).
</details>
# urlCanContainsMetaMatching

@@ -282,5 +177,2 @@

<details>
<summary>urlCanContainsMetaMatching code example</summary>
```js

@@ -311,6 +203,2 @@ import { urlCanContainsMetaMatching } from "@jsenv/url-meta"

— source code at [src/urlCanContainsMetaMatching.js](./src/urlCanContainsMetaMatching.js).
</details>
# urlToMeta

@@ -320,5 +208,2 @@

<details>
<summary>urlToMeta code example</summary>
```js

@@ -343,3 +228,3 @@ import { urlToMeta } from "@jsenv/url-meta"

Console output
_Console output_

@@ -356,4 +241,8 @@ ```console

— source code at [src/urlToMeta.js](./src/urlToMeta.js).
# Installation
</details>
```console
npm install @jsenv/url-meta
```
Can be used in browsers and Node.js.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc