@jsenv/url-meta
Advanced tools
Comparing version 5.0.0 to 5.1.0
@@ -32,3 +32,3 @@ 'use strict'; | ||
// eslint-disable-next-line no-loop-func | ||
ownKeys(source, true).forEach(function (key) { | ||
ownKeys(Object(source), true).forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
@@ -40,3 +40,3 @@ }); | ||
// eslint-disable-next-line no-loop-func | ||
ownKeys(source).forEach(function (key) { | ||
ownKeys(Object(source)).forEach(function (key) { | ||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
@@ -125,3 +125,3 @@ }); | ||
var thirdChar = specifier[2]; | ||
return thirdChar === "/"; | ||
return thirdChar === "/" || thirdChar === "\\"; | ||
}; | ||
@@ -128,0 +128,0 @@ |
{ | ||
"name": "@jsenv/url-meta", | ||
"description": "Associate data to urls using patterns", | ||
"version": "5.0.0", | ||
"version": "5.1.0", | ||
"description": "Associate data to urls using patterns.", | ||
"license": "MIT", | ||
@@ -17,4 +17,6 @@ "repository": { | ||
}, | ||
"type": "module", | ||
"exports": "./index.js", | ||
"module": "index.js", | ||
"main": "dist/commonjs/main.js", | ||
"module": "index.js", | ||
"files": [ | ||
@@ -30,6 +32,9 @@ "/dist/", | ||
"eslint-check": "eslint .", | ||
"prettier-check": "node ./script/prettier-check/prettier-check.js", | ||
"prettier-format": "node ./script/prettier-format/prettier-format.js", | ||
"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-commonjs-bundle": "node ./script/generate-commonjs-bundle/generate-commonjs-bundle.js", | ||
"generate-import-map": "node ./script/generate-import-map/generate-import-map.js", | ||
"install-git-hooks": "node ./script/install-git-hooks/install-git-hooks.js", | ||
"dist": "npm run clean && npm run generate-commonjs-bundle", | ||
@@ -39,16 +44,19 @@ "clean": "rimraf dist && rimraf coverage", | ||
"prepublishOnly": "node ./script/transform-package/remove-postinstall.js && npm run dist", | ||
"postpublish": "node ./script/transform-package/restore-postinstall.js" | ||
"postpublish": "node ./script/transform-package/restore-postinstall.js", | ||
"git-hook-pre-commit": "npm run prettier-format-stage" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@jsenv/assert": "1.1.1", | ||
"@jsenv/codecov-upload": "2.0.0", | ||
"@jsenv/core": "10.0.0-alpha.11", | ||
"@jsenv/eslint-config": "11.3.0", | ||
"@jsenv/assert": "1.2.1", | ||
"@jsenv/codecov-upload": "3.1.0", | ||
"@jsenv/core": "10.5.0", | ||
"@jsenv/eslint-config": "12.1.0", | ||
"@jsenv/git-hooks": "1.2.0", | ||
"@jsenv/github-release-package": "1.1.1", | ||
"@jsenv/node-module-import-map": "8.6.0", | ||
"@jsenv/package-publish": "1.1.0", | ||
"@jsenv/prettier-check-project": "4.0.0", | ||
"@jsenv/node-module-import-map": "10.0.1", | ||
"@jsenv/package-publish": "1.2.0", | ||
"@jsenv/prettier-check-project": "5.1.1", | ||
"@jsenv/prettier-config": "1.1.0", | ||
"eslint": "6.7.2", | ||
"babel-eslint": "11.0.0-beta.0", | ||
"eslint": "6.8.0", | ||
"prettier": "1.19.1", | ||
@@ -55,0 +63,0 @@ "rimraf": "3.0.0" |
164
readme.md
@@ -1,3 +0,5 @@ | ||
# Url meta | ||
# url-meta | ||
Associate data to urls using patterns. | ||
[![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) | ||
@@ -8,10 +10,8 @@ [![npm package](https://img.shields.io/npm/v/@jsenv/url-meta.svg?logo=npm&label=package)](https://www.npmjs.com/package/@jsenv/url-meta) | ||
Associate data to urls using patterns. | ||
## Table of contents | ||
- [Presentation](#Presentation) | ||
- [Code example](#code-example) | ||
- [Pattern matching behaviour](#specifier-pattern-matching-behaviour) | ||
- [api](#api) | ||
- [Installation](#Installation) | ||
- [Documentation](#Documentation) | ||
- [Pattern matching behaviour](#specifier-pattern-matching-behaviour) | ||
- [applySpecifierPatternMatching](#applySpecifierPatternMatching) | ||
@@ -22,12 +22,7 @@ - [metaMapToSpecifierMetaMap](#metaMapToSpecifierMetaMap) | ||
- [urlToMeta](#urlToMeta) | ||
- [Installation](#installation) | ||
## Presentation | ||
# Presentation | ||
`jsenv-url-meta` github repository corresponds to `@jsenv/url-meta` package published on github and npm package registries. | ||
`@jsenv/url-meta` can be used to associate value to urls. You can associate a value to many urls using pattern matching. | ||
## Code example | ||
```js | ||
@@ -62,2 +57,10 @@ import { urlToMeta } from "@jsenv/url-meta" | ||
# Installation | ||
```console | ||
npm install @jsenv/url-meta@5.1.0 | ||
``` | ||
# Documentation | ||
## Pattern matching behaviour | ||
@@ -77,14 +80,6 @@ | ||
## api | ||
## applySpecifierPatternMatching | ||
`@jsenv/url-meta` api is documented here. | ||
`applySpecifierPatternMatching` is a function returning a `matchResult` indicating if and how a `specifier` matches an `url`. | ||
--- | ||
### applySpecifierPatternMatching | ||
> `applySpecifierPatternMatching` is a function returning a `matchResult` indicating if and how a `specifier` matches an `url`.<br /> | ||
Implemented in [src/applySpecifierPatternMatching.js](./src/applySpecifierPatternMatching.js) and could be used as shown below. | ||
```js | ||
@@ -98,87 +93,42 @@ import { applySpecifierPatternMatching } from "@jsenv/url-meta" | ||
console.log(matchResult.matched) | ||
matchResult.matched // true | ||
``` | ||
Logs | ||
— source code at [src/createLogger.js](./src/createLogger.js). | ||
```console | ||
true | ||
``` | ||
### specifier | ||
#### specifier | ||
`specifier` parameter is a string looking like an url but where `*` and `**` can be used so that one specifier can match several url. This parameter is **required**. | ||
> `specifier` is a string looking like an url but where `*` and `**` can be used so that one specifier can match several url. | ||
### url | ||
This parameter is **required**, an example value could be: | ||
`url` parameter is a string representing a url. This parameter is **required**. | ||
```js | ||
"http://example.com/**/*.js" | ||
``` | ||
### matchResult | ||
#### url | ||
`matchResult` represents if and how `specifier` matches `url`. It is returned by `applySpecifierPatternMatching`. | ||
> `url` is a string representing a url. | ||
This parameter is **required**, an example value could be: | ||
```js | ||
"http://example.com/directory/file.js" | ||
``` | ||
#### matchResult | ||
> `matchResult` represents if and how `specifier` matches `url`. | ||
It is returned by `applySpecifierPatternMatching`, see below some example. | ||
##### Matching example | ||
```js | ||
applySpecifierPatternMatching({ | ||
const fullMatch = applySpecifierPatternMatching({ | ||
specifier: "file:///**/*", | ||
url: "file://Users/directory/file.js", | ||
}) | ||
``` | ||
fullMatch // { matched: true, index: 31, patternIndex: 12 } | ||
Returns | ||
```js | ||
{ | ||
matched: true, | ||
index: 31, | ||
patternIndex: 12, | ||
} | ||
``` | ||
Meaning `specifier` fully matched `url`. | ||
##### Failing example | ||
```js | ||
applySpecifierPatternMatching({ | ||
const partialMatch = applySpecifierPatternMatching({ | ||
specifier: "file:///*.js", | ||
url: "file:///file.jsx", | ||
}) | ||
partialMatch // { matched: false, index: 14, patternIndex: 14 } | ||
``` | ||
Returns | ||
fullMatch object indicates `specifier` fully matched `url`.<br /> | ||
partialMatch object indicates `specifier` matched `url` until comparing `url[14]` with `specifier[14]`. | ||
```js | ||
{ | ||
matched: false, | ||
index: 14, | ||
patternIndex: 14, | ||
} | ||
``` | ||
Meaning `specifier` partially matched `url` until comparing `url[14]` with `specifier[14]` | ||
--- | ||
### metaMapToSpecifierMetaMap | ||
## metaMapToSpecifierMetaMap | ||
> `metaMapToSpecifierMetaMap` is a function used to convert a `metaMap` into a `specifierMetaMap`.<br /> | ||
`metaMapToSpecifierMetaMap` is a function used to convert a `metaMap` into a `specifierMetaMap`. | ||
Implemented in [src/metaMapToSpecifierMetaMap.js](./src/metaMapToSpecifierMetaMap.js), you can use it as shown below. | ||
```js | ||
@@ -211,22 +161,18 @@ import { metaMapToSpecifierMetaMap } from "@jsenv/url-meta" | ||
#### metaMap | ||
— source code at [src/metaMapToSpecifierMetaMap.js](./src/metaMapToSpecifierMetaMap.js). | ||
> `metaMap` is an object where values are conditionnaly applied by specifiers. | ||
### metaMap | ||
This parameter is **required**. | ||
`metaMap` parameter is an object where values are conditionnaly applied by specifiers. This parameter is **required**. | ||
#### specifierMetaMap | ||
### specifierMetaMap | ||
> `specifierMetaMap` is an object where meta (other objects) are conditionnaly applied by specifier. | ||
`specifierMetaMap` is an object where meta (other objects) are conditionnaly applied by specifier. It is returned by `metaMapToSpecifierMetaMap`. | ||
It is returned by `metaMapToSpecifierMetaMap`. | ||
--- | ||
### normalizeSpecifierMetaMap | ||
## normalizeSpecifierMetaMap | ||
> `normalizeSpecifierMetaMap` is a function resolving `specifierMetaMap` keys against an `url` | ||
`normalizeSpecifierMetaMap` is a function resolving `specifierMetaMap` keys against an `url`. | ||
Implemented in [src/normalizeSpecifierMetaMap.js](./src/normalizeSpecifierMetaMap.js), you can use it as shown below. | ||
```js | ||
@@ -244,8 +190,10 @@ import { normalizeSpecifierMetaMap } from "@jsenv/url-meta" | ||
### urlCanContainsMetaMatching | ||
— source code at [src/normalizeSpecifierMetaMap.js](./src/normalizeSpecifierMetaMap.js). | ||
> `urlCanContainsMetaMatching` is a function designed to ignore directory content that would never have specific metas. | ||
--- | ||
Implemented in [src/urlCanContainsMetaMatching.js](./src/urlCanContainsMetaMatching.js), you can use it as shown below. | ||
## urlCanContainsMetaMatching | ||
`urlCanContainsMetaMatching` is a function designed to ignore directory content that would never have specific metas. | ||
```js | ||
@@ -288,8 +236,10 @@ import { urlCanContainsMetaMatching } from "@jsenv/url-meta" | ||
### urlToMeta | ||
— source code at [src/urlCanContainsMetaMatching.js](./src/urlCanContainsMetaMatching.js). | ||
> `urlToMeta` is a function returning an object being the composition of all object associated with a matching specifier. | ||
--- | ||
Implemented in [src/urlToMeta.js](./src/urlToMeta.js), you can use it as shown below. | ||
## urlToMeta | ||
`urlToMeta` is a function returning an object being the composition of all object associated with a matching specifier. | ||
```js | ||
@@ -326,14 +276,2 @@ import { urlToMeta } from "@jsenv/url-meta" | ||
## Installation | ||
If you have never installed a jsenv package, read [Installing a jsenv package](https://github.com/jsenv/jsenv-core/blob/master/docs/installing-jsenv-package.md#installing-a-jsenv-package) before going further. | ||
This documentation is up-to-date with a specific version so prefer any of the following commands | ||
```console | ||
npm install --save-dev @jsenv/url-meta@4.1.0 | ||
``` | ||
```console | ||
yarn add --dev @jsenv/url-meta@4.1.0 | ||
``` | ||
— source code at [src/urlToMeta.js](./src/urlToMeta.js). |
@@ -19,5 +19,5 @@ export const assertUrlLike = (value, name = "url") => { | ||
const thirdChar = specifier[2] | ||
return thirdChar === "/" | ||
return thirdChar === "/" || thirdChar === "\\" | ||
} | ||
const hasScheme = (specifier) => /^[a-zA-Z]+:/.test(specifier) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
Yes
53408
14
269