string-extract-sass-vars 3.0.4 → 3.0.10
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/CHANGELOG.md +0 -20
- package/LICENSE +1 -1
- package/README.md +4 -1
- 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 +23 -78
- package/types/index.d.ts +0 -0
- package/examples/api.json +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,26 +3,6 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## 3.0.3 (2021-11-02)
|
|
7
|
-
|
|
8
|
-
### Bug Fixes
|
|
9
|
-
|
|
10
|
-
- bump TS and separate ESLint plugins away from this monorepo ([b1ebce1](https://github.com/codsen/codsen/commit/b1ebce1637d8c41c2d848fc24b0ba4058865bd5d))
|
|
11
|
-
|
|
12
|
-
### Features
|
|
13
|
-
|
|
14
|
-
- migrate to ES Modules ([c579dff](https://github.com/codsen/codsen/commit/c579dff3b23205e383035ca10ddcec671e35d0fe))
|
|
15
|
-
|
|
16
|
-
### BREAKING CHANGES
|
|
17
|
-
|
|
18
|
-
- programs now are in ES Modules and won't work with Common JS require()
|
|
19
|
-
|
|
20
|
-
## 3.0.1 (2021-09-13)
|
|
21
|
-
|
|
22
|
-
### Bug Fixes
|
|
23
|
-
|
|
24
|
-
- bump TS and separate ESLint plugins away from this monorepo ([2e07d42](https://github.com/codsen/codsen/commit/2e07d424222b6ffedf5fb45c83ad453627ec2904))
|
|
25
|
-
|
|
26
6
|
## 3.0.0 (2021-09-09)
|
|
27
7
|
|
|
28
8
|
### Features
|
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2010
|
|
3
|
+
Copyright (c) 2010-2021 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
|
@@ -38,6 +38,7 @@ If you need a legacy version which works with `require`, use version 2.1.0
|
|
|
38
38
|
|
|
39
39
|
```js
|
|
40
40
|
import { strict as assert } from "assert";
|
|
41
|
+
|
|
41
42
|
import { extractVars } from "string-extract-sass-vars";
|
|
42
43
|
|
|
43
44
|
assert.deepEqual(
|
|
@@ -70,7 +71,7 @@ $customValue3: 10;`),
|
|
|
70
71
|
|
|
71
72
|
## Documentation
|
|
72
73
|
|
|
73
|
-
Please [visit codsen.com](https://codsen.com/os/string-extract-sass-vars/) for a full description of the API
|
|
74
|
+
Please [visit codsen.com](https://codsen.com/os/string-extract-sass-vars/) for a full description of the API.
|
|
74
75
|
|
|
75
76
|
## Contributing
|
|
76
77
|
|
|
@@ -82,4 +83,6 @@ MIT License
|
|
|
82
83
|
|
|
83
84
|
Copyright (c) 2010-2021 Roy Revelt and other contributors
|
|
84
85
|
|
|
86
|
+
|
|
85
87
|
<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">
|
|
88
|
+
|
|
@@ -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.10
|
|
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.10";var v=h,S="\\",p={throwIfEmpty:!1,cb:null};function w(t,n){if(typeof t!="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=t.length,$=null,l=null,a=null,i=null,u=null,c=null,s=!1,r=!1,m=!1,b={};for(let e=0;e<g;e++)!s&&u&&t[e]===u&&t[e-1]!==S?u=null:!u&&!s&&t[e-1]!==S&&`'"`.includes(t[e])&&(u=t[e]),r&&`\r
|
|
11
|
+
`.includes(t[e])&&(r=!1),!s&&t[e]==="/"&&t[e+1]==="/"&&(r=!0),m&&t[e-2]==="*"&&t[e-1]==="/"&&(m=!1),!s&&t[e]==="/"&&t[e+1]==="*"&&(m=!0),s=r||m,!s&&t[e]==="$"&&$===null&&($=e+1),!s&&l!==null&&!u&&t[e]===";"&&(i=t.slice(`"'`.includes(t[l])?l+1:l,(c||0)+1),/^-?\d*\.?\d*$/.test(i)&&(i=+i),b[a]=o.cb?o.cb(i):i,$=null,l=null,a=null,i=null),!s&&a!==null&&t[e]&&t[e].trim().length&&l===null&&(l=e),!s&&!a&&$!==null&&t[e]===":"&&!u&&(a=t.slice($,e)),`'"`.includes(t[e])||(c=e);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.10
|
|
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=(e,t,s)=>t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,S=(e,t)=>{for(var s in t||(t={}))p.call(t,s)&&y(e,s,t[s]);if(f)for(var s of f(t))N.call(t,s)&&y(e,s,t[s]);return e};var D=e=>c(e,"__esModule",{value:!0});var C=(e,t)=>{for(var s in t)c(e,s,{get:t[s],enumerable:!0})},A=(e,t,s,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of V(t))!p.call(e,l)&&(s||l!=="default")&&c(e,l,{get:()=>t[l],enumerable:!(r=E(t,l))||r.enumerable});return e};var x=(e=>(t,s)=>e&&e.get(t)||(s=A(D({}),t,1),e&&e.set(t,s),s))(typeof WeakMap!="undefined"?new WeakMap:0);var j={};C(j,{defaults:()=>w,extractVars:()=>J,version:()=>k});var d="3.0.10";var k=d,v="\\",w={throwIfEmpty:!1,cb:null};function J(e,t){var T;if(typeof e!="string")return{};if(t&&typeof t!="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(t,null,4)} (type ${typeof t})`);let s=S(S({},w),t);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(t,null,4)} (type ${typeof t})`);let r=e.length,l=null,u=null,a=null,o=null,$=null,g=null,i=!1,m=!1,b=!1,h={};for(let n=0;n<r;n++)!i&&$&&e[n]===$&&e[n-1]!==v?$=null:!$&&!i&&e[n-1]!==v&&`'"`.includes(e[n])&&($=e[n]),m&&`\r
|
|
11
|
+
`.includes(e[n])&&(m=!1),!i&&e[n]==="/"&&e[n+1]==="/"&&(m=!0),b&&e[n-2]==="*"&&e[n-1]==="/"&&(b=!1),!i&&e[n]==="/"&&e[n+1]==="*"&&(b=!0),i=m||b,!i&&e[n]==="$"&&l===null&&(l=n+1),!i&&u!==null&&!$&&e[n]===";"&&(o=e.slice(`"'`.includes(e[u])?u+1:u,(g||0)+1),/^-?\d*\.?\d*$/.test(o)&&(o=+o),h[a]=s.cb?s.cb(o):o,l=null,u=null,a=null,o=null),!i&&a!==null&&e[n]&&e[n].trim().length&&u===null&&(u=n),!i&&!a&&l!==null&&e[n]===":"&&!$&&(a=e.slice(l,n)),`'"`.includes(e[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.10",
|
|
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,28 @@
|
|
|
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
|
-
"prettier": "../../node_modules/prettier/bin-prettier.js '*.{js,css,scss,vue,md,ts}' --write --loglevel silent",
|
|
51
|
-
"republish": "npm publish || :",
|
|
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",
|
|
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
|
+
"pretest": "yarn run lect && yarn run build",
|
|
48
|
+
"test": "c8 yarn run unit && yarn run examples && yarn run lint",
|
|
49
|
+
"unit": "uvu test"
|
|
58
50
|
},
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
"--no-warnings",
|
|
67
|
-
"--experimental-loader",
|
|
68
|
-
"@istanbuljs/esm-loader-hook"
|
|
51
|
+
"engines": {
|
|
52
|
+
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
|
53
|
+
},
|
|
54
|
+
"c8": {
|
|
55
|
+
"check-coverage": true,
|
|
56
|
+
"exclude": [
|
|
57
|
+
"**/test/**/*.*"
|
|
69
58
|
],
|
|
70
|
-
"
|
|
59
|
+
"lines": 100
|
|
71
60
|
},
|
|
72
61
|
"lect": {
|
|
73
62
|
"licence": {
|
|
@@ -75,53 +64,9 @@
|
|
|
75
64
|
""
|
|
76
65
|
]
|
|
77
66
|
},
|
|
78
|
-
"
|
|
79
|
-
"various": {
|
|
80
|
-
"devDependencies": []
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
"dependencies": {
|
|
84
|
-
"@babel/runtime": "^7.16.0"
|
|
67
|
+
"various": {}
|
|
85
68
|
},
|
|
86
69
|
"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.1.0",
|
|
113
|
-
"lect": "^0.18.4",
|
|
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.0",
|
|
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"
|
|
70
|
+
"color-shorthand-hex-to-six-digit": "^4.0.10"
|
|
126
71
|
}
|
|
127
72
|
}
|
package/types/index.d.ts
CHANGED
|
File without changes
|
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);"}}
|