Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lblod/template-uuid-instantiator
https://github.com/lblod/template-uuid-instantiator
Last synced: 23 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/lblod/template-uuid-instantiator
- Owner: lblod
- License: mit
- Created: 2024-06-04T09:24:07.000Z (7 months ago)
- Default Branch: master
- Last Pushed: 2024-11-15T15:02:20.000Z (about 1 month ago)
- Last Synced: 2024-11-15T15:32:57.636Z (about 1 month ago)
- Language: TypeScript
- Size: 120 KB
- Stars: 0
- Watchers: 5
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Template Uuid Instantiator
This package allows you to instantiate uris of a string.
## Usage
The utility loops over the text supplied and identifies the strings with the form `"https://example.org/--ref-algorithm-123-456-abc"`, we will explain each part below. It allows both " and ' , as well as HTML entities (such as `"`). Quote types will be preserved.
- Base uri: In the example is the `https://example.org/` part, this part will be preserved in the result uri
- Uuid: This part is the `--ref-algorithm-123-456-abc` in the example. it has itself 3 parts:
- --ref: This will be ignored in the result, it indicates you want this uri to be replaced
- algorithm: It will indicate which algorithm will be used to generate the uuid, look at the algorithms section to see which ones are supported
- 123-456-abc: This is an uuid that is used as memoization, combinations of the same base uri and uuid will generate the same uri. If they have different algorithms the first one that appears on the string will be used.## Algorithms
The following algorithms are supported:
- uuid4: This uses the uuidv4 algorithm from the uuid npm package [https://www.npmjs.com/package/uuid](https://www.npmjs.com/package/uuid). This will be the default algorithm used if the specified one is not found. An example on how to use this algorithm would be `"https://example.org/--ref-uuid4-123-456-abc"`
## Example
This is an example of a small app using the library
```js
import templateUuidInstantiator from '@lblod/template-uuid-instantiator';const document = `
`;const instantiatedDocument = templateUuidInstantiator(document);
```