@flex-development/docmark-util-combine-extensions 1.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +28 -0
- package/README.md +86 -0
- package/dist/index.d.mts +39 -0
- package/dist/index.mjs +41 -0
- package/package.json +63 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026, Flex Development, LLC All rights reserved.
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without modification,
|
|
6
|
+
are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its contributors
|
|
16
|
+
may be used to endorse or promote products derived from this software without
|
|
17
|
+
specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
20
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
21
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
|
23
|
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
24
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
25
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
26
|
+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
27
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
28
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# docmark-util-combine-extensions
|
|
2
|
+
|
|
3
|
+
[](https://npmjs.com/package/@flex-development/docmark-util-combine-extensions)
|
|
4
|
+
[](https://www.npmcharts.com/compare/@flex-development/docmark-util-combine-extensions?interval=30)
|
|
5
|
+
[](https://packagephobia.now.sh/result?p=@flex-development/docmark-util-combine-extensions)
|
|
6
|
+
[](https://github.com/voxpelli/badges-cjs-esm)
|
|
7
|
+
|
|
8
|
+
[docmark][] utility to combine extensions.
|
|
9
|
+
|
|
10
|
+
## Contents
|
|
11
|
+
|
|
12
|
+
- [What is this?](#what-is-this)
|
|
13
|
+
- [When should I use this?](#when-should-i-use-this)
|
|
14
|
+
- [Install](#install)
|
|
15
|
+
- [Use](#use)
|
|
16
|
+
- [API](#api)
|
|
17
|
+
- [Types](#types)
|
|
18
|
+
- [Contribute](#contribute)
|
|
19
|
+
|
|
20
|
+
## What is this?
|
|
21
|
+
|
|
22
|
+
This package can merge multiple syntax extensions into one.
|
|
23
|
+
|
|
24
|
+
## When should I use this?
|
|
25
|
+
|
|
26
|
+
This package is useful when building docmark extensions.
|
|
27
|
+
|
|
28
|
+
## Install
|
|
29
|
+
|
|
30
|
+
This package is [ESM only][esm].
|
|
31
|
+
|
|
32
|
+
In Node.js with [yarn][]:
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
yarn add @flex-development/docmark-util-combine-extensions
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
<blockquote>
|
|
39
|
+
<small>
|
|
40
|
+
See <a href='https://yarnpkg.com/protocol/git'>Git - Protocols | Yarn</a>
|
|
41
|
+
for details regarding installing from Git.
|
|
42
|
+
</small>
|
|
43
|
+
</blockquote>
|
|
44
|
+
|
|
45
|
+
In Deno with [`esm.sh`][esmsh]:
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import { combineExtensions } from 'https://esm.sh/@flex-development/docmark-util-combine-extensions'
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
In browsers with [`esm.sh`][esmsh]:
|
|
52
|
+
|
|
53
|
+
```html
|
|
54
|
+
<script type="module">
|
|
55
|
+
import { combineExtensions } from 'https://esm.sh/@flex-development/docmark-util-combine-extensions'
|
|
56
|
+
</script>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Use
|
|
60
|
+
|
|
61
|
+
**TODO**: use
|
|
62
|
+
|
|
63
|
+
## API
|
|
64
|
+
|
|
65
|
+
**TODO**: api
|
|
66
|
+
|
|
67
|
+
## Types
|
|
68
|
+
|
|
69
|
+
This package is fully typed with [TypeScript][].
|
|
70
|
+
|
|
71
|
+
## Contribute
|
|
72
|
+
|
|
73
|
+
See [`CONTRIBUTING.md`](../../CONTRIBUTING.md).
|
|
74
|
+
|
|
75
|
+
This project has a [code of conduct](../../CODE_OF_CONDUCT.md).
|
|
76
|
+
By interacting with this repository, organization, or community you agree to abide by its terms.
|
|
77
|
+
|
|
78
|
+
[docmark]: ../../README.md
|
|
79
|
+
|
|
80
|
+
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
|
81
|
+
|
|
82
|
+
[esmsh]: https://esm.sh
|
|
83
|
+
|
|
84
|
+
[typescript]: https://www.typescriptlang.org
|
|
85
|
+
|
|
86
|
+
[yarn]: https://yarnpkg.com
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { NormalizedExtension, AnyExtension } from '@flex-development/docmark-util-types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file combineExtensions
|
|
5
|
+
* @module docmark-util-combine-extensions
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Combine multiple extensions into one.
|
|
10
|
+
*
|
|
11
|
+
* @see {@linkcode AnyExtension}
|
|
12
|
+
* @see {@linkcode NormalizedExtension}
|
|
13
|
+
*
|
|
14
|
+
* @template {NormalizedExtension} T
|
|
15
|
+
* The combined extension
|
|
16
|
+
*
|
|
17
|
+
* @param {AnyExtension | AnyExtension[] | null | undefined} extensions
|
|
18
|
+
* The extension or list of extensions
|
|
19
|
+
* @return {T}
|
|
20
|
+
* The combined extension
|
|
21
|
+
*/
|
|
22
|
+
declare function combineExtensions<T extends NormalizedExtension>(extensions: AnyExtension | AnyExtension[] | null | undefined): T;
|
|
23
|
+
/**
|
|
24
|
+
* Combine multiple extensions into one.
|
|
25
|
+
*
|
|
26
|
+
* @see {@linkcode AnyExtension}
|
|
27
|
+
* @see {@linkcode NormalizedExtension}
|
|
28
|
+
*
|
|
29
|
+
* @template {NormalizedExtension} T
|
|
30
|
+
* The combined extension
|
|
31
|
+
*
|
|
32
|
+
* @param {(AnyExtension | AnyExtension[] | null | undefined)[]} extensions
|
|
33
|
+
* The extensions to combine
|
|
34
|
+
* @return {T}
|
|
35
|
+
* The combined extension
|
|
36
|
+
*/
|
|
37
|
+
declare function combineExtensions<T extends NormalizedExtension>(...extensions: (AnyExtension | AnyExtension[] | null | undefined)[]): T;
|
|
38
|
+
|
|
39
|
+
export { combineExtensions, combineExtensions as default };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { splice } from '@flex-development/mark-util-chunked';
|
|
2
|
+
import { ok } from 'devlop';
|
|
3
|
+
|
|
4
|
+
function combineExtensions(extensions, ...sources) {
|
|
5
|
+
const all = {};
|
|
6
|
+
const list = [extensions, ...sources].filter(s => !!s).flat();
|
|
7
|
+
let index = -1;
|
|
8
|
+
while (++index < list.length) {
|
|
9
|
+
const extension = list[index];
|
|
10
|
+
let hook;
|
|
11
|
+
for (hook in (ok(extension, 'expected `extension`'), extension)) {
|
|
12
|
+
const maybe = Object.hasOwnProperty.call(all, hook)
|
|
13
|
+
? all[hook]
|
|
14
|
+
: undefined;
|
|
15
|
+
const left = maybe ?? (all[hook] = {});
|
|
16
|
+
const right = extension[hook];
|
|
17
|
+
if (right) {
|
|
18
|
+
let key;
|
|
19
|
+
for (key in right) {
|
|
20
|
+
if (!Object.hasOwnProperty.call(left, key))
|
|
21
|
+
left[key] = [];
|
|
22
|
+
merge(toList(left[key]), toList(right[key] ?? []));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return all;
|
|
28
|
+
}
|
|
29
|
+
function merge(existing, list) {
|
|
30
|
+
const before = [];
|
|
31
|
+
let index = -1;
|
|
32
|
+
while (++index < list.length) {
|
|
33
|
+
(list[index].add === 'after' ? existing : before).push(list[index]);
|
|
34
|
+
}
|
|
35
|
+
return void splice(existing, 0, 0, before);
|
|
36
|
+
}
|
|
37
|
+
function toList(value) {
|
|
38
|
+
return (Array.isArray(value) ? value : [value]);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export { combineExtensions, combineExtensions as default };
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@flex-development/docmark-util-combine-extensions",
|
|
3
|
+
"description": "docmark utility to combine extensions",
|
|
4
|
+
"version": "1.0.0-alpha.1",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"docmark",
|
|
7
|
+
"extension",
|
|
8
|
+
"tokenize",
|
|
9
|
+
"typescript",
|
|
10
|
+
"util",
|
|
11
|
+
"utility"
|
|
12
|
+
],
|
|
13
|
+
"license": "BSD-3-Clause",
|
|
14
|
+
"homepage": "https://github.com/flex-development/docmark-util-types/tree/main/packages/flex-development/docmark-util-combine-extensions",
|
|
15
|
+
"repository": {
|
|
16
|
+
"directory": "packages/docmark-util-combine-extensions",
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/flex-development/docmark.git"
|
|
19
|
+
},
|
|
20
|
+
"bugs": "https://github.com/flex-development/docmark/issues",
|
|
21
|
+
"author": {
|
|
22
|
+
"name": "Lexus Drumgold",
|
|
23
|
+
"url": "https://github.com/unicornware"
|
|
24
|
+
},
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public",
|
|
27
|
+
"diff-dst-prefix": "docmark-util-combine-extensions",
|
|
28
|
+
"diff-src-prefix": "docmark-util-combine-extensions",
|
|
29
|
+
"directory": "./",
|
|
30
|
+
"executableFiles": [],
|
|
31
|
+
"node-options": null,
|
|
32
|
+
"pack-destination": ".",
|
|
33
|
+
"parseable": true,
|
|
34
|
+
"prefer-dedupe": true,
|
|
35
|
+
"provenance": true,
|
|
36
|
+
"tag-version-prefix": "docmark-util-combine-extensions"
|
|
37
|
+
},
|
|
38
|
+
"type": "module",
|
|
39
|
+
"files": [
|
|
40
|
+
"LICENSE.md",
|
|
41
|
+
"README.md",
|
|
42
|
+
"dist"
|
|
43
|
+
],
|
|
44
|
+
"exports": {
|
|
45
|
+
".": {
|
|
46
|
+
"docmark": "./src/index.mts",
|
|
47
|
+
"default": "./dist/index.mjs"
|
|
48
|
+
},
|
|
49
|
+
"./package.json": "./package.json"
|
|
50
|
+
},
|
|
51
|
+
"imports": {
|
|
52
|
+
"#fixtures/*": "./__fixtures__/*.mts"
|
|
53
|
+
},
|
|
54
|
+
"module": "./dist/index.mjs",
|
|
55
|
+
"types": "./dist/index.d.mts",
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"@flex-development/docmark-util-types": "1.0.0-alpha.1",
|
|
58
|
+
"@flex-development/mark-util-chunked": "1.0.0",
|
|
59
|
+
"devlop": "1.1.0"
|
|
60
|
+
},
|
|
61
|
+
"sideEffects": false,
|
|
62
|
+
"build": "524f7d653272a777cde27efaac4656fb90cd4855"
|
|
63
|
+
}
|