string-extract-sass-vars 3.0.5 → 3.0.11
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 +1 -1
- package/README.md +4 -5
- package/dist/string-extract-sass-vars.esm.js +3 -84
- package/dist/string-extract-sass-vars.umd.js +3 -2
- package/examples/_quickTake.js +1 -0
- package/examples/opts-cb.js +2 -1
- package/examples/throw-if-empty.js +1 -0
- package/package.json +25 -78
- package/types/index.d.ts +7 -4
- package/examples/api.json +0 -1
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2010-
|
|
3
|
+
Copyright (c) 2010-2022 Roy Revelt and other contributors
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
6
|
a copy of this software and associated documentation files (the
|
package/README.md
CHANGED
|
@@ -26,18 +26,17 @@
|
|
|
26
26
|
|
|
27
27
|
## Install
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
The latest version is **ESM only**: Node 12+ is needed to use it and it must be `import`ed instead of `require`d. If your project is not on ESM yet and you want to use `require`, use an older version of this program, `2.1.0`.
|
|
30
30
|
|
|
31
31
|
```bash
|
|
32
32
|
npm i string-extract-sass-vars
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
If you need a legacy version which works with `require`, use version 2.1.0
|
|
36
|
-
|
|
37
35
|
## Quick Take
|
|
38
36
|
|
|
39
37
|
```js
|
|
40
38
|
import { strict as assert } from "assert";
|
|
39
|
+
|
|
41
40
|
import { extractVars } from "string-extract-sass-vars";
|
|
42
41
|
|
|
43
42
|
assert.deepEqual(
|
|
@@ -70,7 +69,7 @@ $customValue3: 10;`),
|
|
|
70
69
|
|
|
71
70
|
## Documentation
|
|
72
71
|
|
|
73
|
-
Please [visit codsen.com](https://codsen.com/os/string-extract-sass-vars/) for a full description of the API
|
|
72
|
+
Please [visit codsen.com](https://codsen.com/os/string-extract-sass-vars/) for a full description of the API.
|
|
74
73
|
|
|
75
74
|
## Contributing
|
|
76
75
|
|
|
@@ -80,6 +79,6 @@ To report bugs or request features or assistance, [raise an issue](https://githu
|
|
|
80
79
|
|
|
81
80
|
MIT License
|
|
82
81
|
|
|
83
|
-
Copyright (c) 2010-
|
|
82
|
+
Copyright (c) 2010-2022 Roy Revelt and other contributors
|
|
84
83
|
|
|
85
84
|
<img src="https://codsen.com/images/png-codsen-ok.png" width="98" alt="ok" align="center"> <img src="https://codsen.com/images/png-codsen-1.png" width="148" alt="codsen" align="center"> <img src="https://codsen.com/images/png-codsen-star-small.png" width="32" alt="star" align="center">
|
|
@@ -1,92 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name string-extract-sass-vars
|
|
3
3
|
* @fileoverview Parse SASS variables file into a plain object of CSS key-value pairs
|
|
4
|
-
* @version 3.0.
|
|
4
|
+
* @version 3.0.11
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/string-extract-sass-vars/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
const version = version$1;
|
|
13
|
-
const BACKSLASH = "\u005C";
|
|
14
|
-
const defaults = {
|
|
15
|
-
throwIfEmpty: false,
|
|
16
|
-
cb: null
|
|
17
|
-
};
|
|
18
|
-
function extractVars(str, originalOpts) {
|
|
19
|
-
if (typeof str !== "string") {
|
|
20
|
-
return {};
|
|
21
|
-
}
|
|
22
|
-
if (originalOpts && typeof originalOpts !== "object") {
|
|
23
|
-
throw new Error(`string-extract-sass-vars: [THROW_ID_01] the second input argument should be a plain object but it was given as ${JSON.stringify(originalOpts, null, 4)} (type ${typeof originalOpts})`);
|
|
24
|
-
}
|
|
25
|
-
const opts = { ...defaults,
|
|
26
|
-
...originalOpts
|
|
27
|
-
};
|
|
28
|
-
if (opts.cb && typeof opts.cb !== "function") {
|
|
29
|
-
throw new Error(`string-extract-sass-vars: [THROW_ID_02] opts.cb should be function! But it was given as ${JSON.stringify(originalOpts, null, 4)} (type ${typeof originalOpts})`);
|
|
30
|
-
}
|
|
31
|
-
const len = str.length;
|
|
32
|
-
let varNameStartsAt = null;
|
|
33
|
-
let varValueStartsAt = null;
|
|
34
|
-
let varName = null;
|
|
35
|
-
let varValue = null;
|
|
36
|
-
let withinQuotes = null;
|
|
37
|
-
let lastNonQuoteCharAt = null;
|
|
38
|
-
let withinComments = false;
|
|
39
|
-
let withinSlashSlashComment = false;
|
|
40
|
-
let withinSlashAsteriskComment = false;
|
|
41
|
-
const res = {};
|
|
42
|
-
for (let i = 0; i < len; i++) {
|
|
43
|
-
if (!withinComments && withinQuotes && str[i] === withinQuotes && str[i - 1] !== BACKSLASH) {
|
|
44
|
-
withinQuotes = null;
|
|
45
|
-
}
|
|
46
|
-
else if (!withinQuotes && !withinComments && str[i - 1] !== BACKSLASH && `'"`.includes(str[i])) {
|
|
47
|
-
withinQuotes = str[i];
|
|
48
|
-
}
|
|
49
|
-
if (withinSlashSlashComment && `\r\n`.includes(str[i])) {
|
|
50
|
-
withinSlashSlashComment = false;
|
|
51
|
-
}
|
|
52
|
-
if (!withinComments && str[i] === "/" && str[i + 1] === "/") {
|
|
53
|
-
withinSlashSlashComment = true;
|
|
54
|
-
}
|
|
55
|
-
if (withinSlashAsteriskComment && str[i - 2] === "*" && str[i - 1] === "/") {
|
|
56
|
-
withinSlashAsteriskComment = false;
|
|
57
|
-
}
|
|
58
|
-
if (!withinComments && str[i] === "/" && str[i + 1] === "*") {
|
|
59
|
-
withinSlashAsteriskComment = true;
|
|
60
|
-
}
|
|
61
|
-
withinComments = withinSlashSlashComment || withinSlashAsteriskComment;
|
|
62
|
-
if (!withinComments && str[i] === "$" && varNameStartsAt === null) {
|
|
63
|
-
varNameStartsAt = i + 1;
|
|
64
|
-
}
|
|
65
|
-
if (!withinComments && varValueStartsAt !== null && !withinQuotes && str[i] === ";") {
|
|
66
|
-
varValue = str.slice(!`"'`.includes(str[varValueStartsAt]) ? varValueStartsAt : varValueStartsAt + 1, (lastNonQuoteCharAt || 0) + 1);
|
|
67
|
-
if (/^-?\d*\.?\d*$/.test(varValue)) {
|
|
68
|
-
varValue = +varValue;
|
|
69
|
-
}
|
|
70
|
-
res[varName] = opts.cb ? opts.cb(varValue) : varValue;
|
|
71
|
-
varNameStartsAt = null;
|
|
72
|
-
varValueStartsAt = null;
|
|
73
|
-
varName = null;
|
|
74
|
-
varValue = null;
|
|
75
|
-
}
|
|
76
|
-
if (!withinComments && varName !== null && str[i] && str[i].trim().length && varValueStartsAt === null) {
|
|
77
|
-
varValueStartsAt = i;
|
|
78
|
-
}
|
|
79
|
-
if (!withinComments && !varName && varNameStartsAt !== null && str[i] === ":" && !withinQuotes) {
|
|
80
|
-
varName = str.slice(varNameStartsAt, i);
|
|
81
|
-
}
|
|
82
|
-
if (!`'"`.includes(str[i])) {
|
|
83
|
-
lastNonQuoteCharAt = i;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
if (!Object.keys(res).length && opts.throwIfEmpty) {
|
|
87
|
-
throw new Error(`string-extract-sass-vars: [THROW_ID_03] no keys extracted! (setting opts.originalOpts)`);
|
|
88
|
-
}
|
|
89
|
-
return res;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export { defaults, extractVars, version };
|
|
10
|
+
var h="3.0.11";var v=h,S="\\",p={throwIfEmpty:!1,cb:null};function w(e,n){if(typeof e!="string")return{};if(n&&typeof n!="object")throw new Error(`string-extract-sass-vars: [THROW_ID_01] the second input argument should be a plain object but it was given as ${JSON.stringify(n,null,4)} (type ${typeof n})`);let o={...p,...n};if(o.cb&&typeof o.cb!="function")throw new Error(`string-extract-sass-vars: [THROW_ID_02] opts.cb should be function! But it was given as ${JSON.stringify(n,null,4)} (type ${typeof n})`);let g=e.length,r=null,l=null,$=null,i=null,u=null,c=null,s=!1,a=!1,m=!1,b={};for(let t=0;t<g;t++)!s&&u&&e[t]===u&&e[t-1]!==S?u=null:!u&&!s&&e[t-1]!==S&&`'"`.includes(e[t])&&(u=e[t]),a&&`\r
|
|
11
|
+
`.includes(e[t])&&(a=!1),!s&&e[t]==="/"&&e[t+1]==="/"&&(a=!0),m&&e[t-2]==="*"&&e[t-1]==="/"&&(m=!1),!s&&e[t]==="/"&&e[t+1]==="*"&&(m=!0),s=a||m,!s&&e[t]==="$"&&r===null&&(r=t+1),!s&&l!==null&&!u&&e[t]===";"&&(i=e.slice(`"'`.includes(e[l])?l+1:l,(c||0)+1),/^-?\d*\.?\d*$/.test(i)&&(i=+i),b[$]=o.cb?o.cb(i):i,r=null,l=null,$=null,i=null),!s&&$!==null&&e[t]&&e[t].trim().length&&l===null&&(l=t),!s&&!$&&r!==null&&e[t]===":"&&!u&&($=e.slice(r,t)),`'"`.includes(e[t])||(c=t);if(!Object.keys(b).length&&o.throwIfEmpty)throw new Error("string-extract-sass-vars: [THROW_ID_03] no keys extracted! (setting opts.originalOpts)");return b}export{p as defaults,w as extractVars,v as version};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name string-extract-sass-vars
|
|
3
3
|
* @fileoverview Parse SASS variables file into a plain object of CSS key-value pairs
|
|
4
|
-
* @version 3.0.
|
|
4
|
+
* @version 3.0.11
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/string-extract-sass-vars/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
var stringExtractSassVars=(()=>{var c=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames,f=Object.getOwnPropertySymbols;var p=Object.prototype.hasOwnProperty,N=Object.prototype.propertyIsEnumerable;var y=(t,e,s)=>e in t?c(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,S=(t,e)=>{for(var s in e||(e={}))p.call(e,s)&&y(t,s,e[s]);if(f)for(var s of f(e))N.call(e,s)&&y(t,s,e[s]);return t};var D=t=>c(t,"__esModule",{value:!0});var C=(t,e)=>{for(var s in e)c(t,s,{get:e[s],enumerable:!0})},A=(t,e,s,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let l of V(e))!p.call(t,l)&&(s||l!=="default")&&c(t,l,{get:()=>e[l],enumerable:!(a=E(e,l))||a.enumerable});return t};var x=(t=>(e,s)=>t&&t.get(e)||(s=A(D({}),e,1),t&&t.set(e,s),s))(typeof WeakMap!="undefined"?new WeakMap:0);var j={};C(j,{defaults:()=>w,extractVars:()=>J,version:()=>k});var d="3.0.11";var k=d,v="\\",w={throwIfEmpty:!1,cb:null};function J(t,e){var T;if(typeof t!="string")return{};if(e&&typeof e!="object")throw new Error(`string-extract-sass-vars: [THROW_ID_01] the second input argument should be a plain object but it was given as ${JSON.stringify(e,null,4)} (type ${typeof e})`);let s=S(S({},w),e);if(s.cb&&typeof s.cb!="function")throw new Error(`string-extract-sass-vars: [THROW_ID_02] opts.cb should be function! But it was given as ${JSON.stringify(e,null,4)} (type ${typeof e})`);let a=t.length,l=null,u=null,$=null,o=null,r=null,g=null,i=!1,m=!1,b=!1,h={};for(let n=0;n<a;n++)!i&&r&&t[n]===r&&t[n-1]!==v?r=null:!r&&!i&&t[n-1]!==v&&`'"`.includes(t[n])&&(r=t[n]),m&&`\r
|
|
11
|
+
`.includes(t[n])&&(m=!1),!i&&t[n]==="/"&&t[n+1]==="/"&&(m=!0),b&&t[n-2]==="*"&&t[n-1]==="/"&&(b=!1),!i&&t[n]==="/"&&t[n+1]==="*"&&(b=!0),i=m||b,!i&&t[n]==="$"&&l===null&&(l=n+1),!i&&u!==null&&!r&&t[n]===";"&&(o=t.slice(`"'`.includes(t[u])?u+1:u,(g||0)+1),/^-?\d*\.?\d*$/.test(o)&&(o=+o),h[$]=s.cb?s.cb(o):o,l=null,u=null,$=null,o=null),!i&&$!==null&&t[n]&&t[n].trim().length&&u===null&&(u=n),!i&&!$&&l!==null&&t[n]===":"&&!r&&($=t.slice(l,n)),`'"`.includes(t[n])||(g=n);if(!Object.keys(h).length&&s.throwIfEmpty)throw new Error("string-extract-sass-vars: [THROW_ID_03] no keys extracted! (setting opts.originalOpts)");return h}return x(j);})();
|
package/examples/_quickTake.js
CHANGED
package/examples/opts-cb.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// Convert 3-digit color hex codes to 6-digit
|
|
2
2
|
|
|
3
3
|
import { strict as assert } from "assert";
|
|
4
|
+
import { conv } from "color-shorthand-hex-to-six-digit";
|
|
5
|
+
|
|
4
6
|
import { extractVars } from "../dist/string-extract-sass-vars.esm.js";
|
|
5
7
|
// import "color-shorthand-hex-to-six-digit" to convert three-digit colour hex
|
|
6
8
|
// codes to six-digit:
|
|
7
|
-
import { conv } from "../../color-shorthand-hex-to-six-digit/dist/color-shorthand-hex-to-six-digit.esm.js";
|
|
8
9
|
|
|
9
10
|
assert.deepEqual(
|
|
10
11
|
extractVars("$blue: #2af;", {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "string-extract-sass-vars",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.11",
|
|
4
4
|
"description": "Parse SASS variables file into a plain object of CSS key-value pairs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"css",
|
|
@@ -35,39 +35,30 @@
|
|
|
35
35
|
},
|
|
36
36
|
"types": "types/index.d.ts",
|
|
37
37
|
"scripts": {
|
|
38
|
-
"build": "
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"tap": "tap",
|
|
53
|
-
"pretest": "npm run build",
|
|
54
|
-
"test": "npm run lint && npm run unittest && npm run test:examples && npm run clean_cov && npm run format",
|
|
55
|
-
"test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
|
|
56
|
-
"tsc": "tsc",
|
|
57
|
-
"unittest": "tap --no-only --output-file=testStats.md --reporter=terse && tsc -p tsconfig.json --noEmit && npm run clean_cov && npm run perf"
|
|
38
|
+
"build": "node '../../ops/scripts/esbuild.js' && yarn run dts",
|
|
39
|
+
"dev": "DEV=true node '../../ops/scripts/esbuild.js' && yarn run dts",
|
|
40
|
+
"dts": "rollup -c && yarn run prettier 'types/index.d.ts' --write",
|
|
41
|
+
"examples": "node '../../ops/scripts/run-examples.js'",
|
|
42
|
+
"lect": "node '../../ops/lect/lect.js'",
|
|
43
|
+
"letspublish": "yarn publish || :",
|
|
44
|
+
"lint": "eslint . --fix",
|
|
45
|
+
"perf": "node perf/check.js",
|
|
46
|
+
"prepare": "echo 'ready'",
|
|
47
|
+
"prettier": "prettier",
|
|
48
|
+
"prettier:format": "prettier --write '**/*.{ts,tsx,md}' --no-error-on-unmatched-pattern",
|
|
49
|
+
"pretest": "yarn run lect && yarn run build",
|
|
50
|
+
"test": "c8 yarn run unit && yarn run examples && yarn run lint",
|
|
51
|
+
"unit": "uvu test"
|
|
58
52
|
},
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
"--no-warnings",
|
|
67
|
-
"--experimental-loader",
|
|
68
|
-
"@istanbuljs/esm-loader-hook"
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
|
55
|
+
},
|
|
56
|
+
"c8": {
|
|
57
|
+
"check-coverage": true,
|
|
58
|
+
"exclude": [
|
|
59
|
+
"**/test/**/*.*"
|
|
69
60
|
],
|
|
70
|
-
"
|
|
61
|
+
"lines": 100
|
|
71
62
|
},
|
|
72
63
|
"lect": {
|
|
73
64
|
"licence": {
|
|
@@ -75,53 +66,9 @@
|
|
|
75
66
|
""
|
|
76
67
|
]
|
|
77
68
|
},
|
|
78
|
-
"
|
|
79
|
-
"various": {
|
|
80
|
-
"devDependencies": []
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
"dependencies": {
|
|
84
|
-
"@babel/runtime": "^7.16.0"
|
|
69
|
+
"various": {}
|
|
85
70
|
},
|
|
86
71
|
"devDependencies": {
|
|
87
|
-
"
|
|
88
|
-
"@babel/core": "^7.16.0",
|
|
89
|
-
"@babel/node": "^7.16.0",
|
|
90
|
-
"@babel/plugin-external-helpers": "^7.16.0",
|
|
91
|
-
"@babel/plugin-proposal-class-properties": "^7.16.0",
|
|
92
|
-
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
|
|
93
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.16.0",
|
|
94
|
-
"@babel/plugin-proposal-optional-chaining": "^7.16.0",
|
|
95
|
-
"@babel/plugin-transform-runtime": "^7.16.0",
|
|
96
|
-
"@babel/preset-env": "^7.16.0",
|
|
97
|
-
"@babel/preset-typescript": "^7.16.0",
|
|
98
|
-
"@babel/register": "^7.16.0",
|
|
99
|
-
"@istanbuljs/esm-loader-hook": "^0.1.2",
|
|
100
|
-
"@rollup/plugin-babel": "^5.3.0",
|
|
101
|
-
"@rollup/plugin-commonjs": "^21.0.1",
|
|
102
|
-
"@rollup/plugin-json": "^4.1.0",
|
|
103
|
-
"@rollup/plugin-node-resolve": "^13.0.6",
|
|
104
|
-
"@rollup/plugin-strip": "^2.1.0",
|
|
105
|
-
"@rollup/plugin-typescript": "^8.3.0",
|
|
106
|
-
"@types/node": "^16.11.6",
|
|
107
|
-
"@types/tap": "^15.0.5",
|
|
108
|
-
"@typescript-eslint/eslint-plugin": "^5.3.0",
|
|
109
|
-
"@typescript-eslint/parser": "^5.3.0",
|
|
110
|
-
"core-js": "^3.19.1",
|
|
111
|
-
"cross-env": "^7.0.3",
|
|
112
|
-
"eslint": "^8.2.0",
|
|
113
|
-
"lect": "^0.18.5",
|
|
114
|
-
"rollup": "^2.59.0",
|
|
115
|
-
"rollup-plugin-ascii": "^0.0.3",
|
|
116
|
-
"rollup-plugin-banner": "^0.2.1",
|
|
117
|
-
"rollup-plugin-cleanup": "^3.2.1",
|
|
118
|
-
"rollup-plugin-dts": "^4.0.1",
|
|
119
|
-
"rollup-plugin-terser": "^7.0.2",
|
|
120
|
-
"tap": "^15.0.10",
|
|
121
|
-
"tslib": "^2.3.1",
|
|
122
|
-
"typescript": "^4.4.4"
|
|
123
|
-
},
|
|
124
|
-
"engines": {
|
|
125
|
-
"node": ">=12"
|
|
72
|
+
"color-shorthand-hex-to-six-digit": "^4.0.11"
|
|
126
73
|
}
|
|
127
74
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
declare const version: string;
|
|
2
2
|
interface UnknownValueObj {
|
|
3
|
-
|
|
3
|
+
[key: string]: any;
|
|
4
4
|
}
|
|
5
5
|
interface Opts {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
throwIfEmpty?: boolean;
|
|
7
|
+
cb?: null | ((varValue: string) => any);
|
|
8
8
|
}
|
|
9
9
|
declare const defaults: Opts;
|
|
10
|
-
declare function extractVars(
|
|
10
|
+
declare function extractVars(
|
|
11
|
+
str: string,
|
|
12
|
+
originalOpts?: Partial<Opts>
|
|
13
|
+
): UnknownValueObj;
|
|
11
14
|
|
|
12
15
|
export { defaults, extractVars, version };
|
package/examples/api.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"_quickTake.js":{"title":"Quick Take","content":"import { strict as assert } from \"assert\";\nimport { extractVars } from \"string-extract-sass-vars\";\n\nassert.deepEqual(\n extractVars(`// all variables are here!!!\n// ------------------------------------------\n$red: #ff6565; // this is red\n// $green: #63ffbd; // no green here\n$yellow: #ffff65; // this is yellow\n$blue: #08f0fd; // this is blue\n$fontfamily: Helvetica, sans-serif;\n$border: 1px solid #dedede;\n$borderroundedness: 3px;\n$customValue1: tralala;\n$customValue2: tralala;\n// don't mind this comment about #ff6565;\n$customValue3: 10;`),\n {\n red: \"#ff6565\",\n yellow: \"#ffff65\",\n blue: \"#08f0fd\",\n fontfamily: \"Helvetica, sans-serif\",\n border: \"1px solid #dedede\",\n borderroundedness: \"3px\",\n customValue1: \"tralala\",\n customValue2: \"tralala\",\n customValue3: 10,\n }\n);"},"opts-cb.js":{"title":"Convert 3-digit color hex codes to 6-digit","content":"import { strict as assert } from \"assert\";\nimport { extractVars } from \"string-extract-sass-vars\";\n// import \"color-shorthand-hex-to-six-digit\" to convert three-digit colour hex\n// codes to six-digit:\nimport { conv } from \"color-shorthand-hex-to-six-digit\";\n\nassert.deepEqual(\n extractVars(\"$blue: #2af;\", {\n throwIfEmpty: true,\n cb: (val) => conv(val), // converts hex codes only, bypasses the rest\n }),\n { blue: \"#22aaff\" }\n);"},"throw-if-empty.js":{"title":"Raises alarm if variables file has been wiped","content":"import { strict as assert } from \"assert\";\nimport { extractVars } from \"string-extract-sass-vars\";\n\nassert.throws(() =>\n extractVars(\"\", {\n throwIfEmpty: true,\n })\n);"}}
|