string-extract-sass-vars 3.0.10 → 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 +2 -6
- package/dist/string-extract-sass-vars.esm.js +3 -3
- package/dist/string-extract-sass-vars.umd.js +3 -3
- package/package.json +5 -3
- package/types/index.d.ts +7 -4
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,14 +26,12 @@
|
|
|
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
|
|
@@ -81,8 +79,6 @@ To report bugs or request features or assistance, [raise an issue](https://githu
|
|
|
81
79
|
|
|
82
80
|
MIT License
|
|
83
81
|
|
|
84
|
-
Copyright (c) 2010-
|
|
85
|
-
|
|
82
|
+
Copyright (c) 2010-2022 Roy Revelt and other contributors
|
|
86
83
|
|
|
87
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">
|
|
88
|
-
|
|
@@ -1,11 +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 h="3.0.
|
|
11
|
-
`.includes(t
|
|
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,11 +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 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,
|
|
11
|
-
`.includes(
|
|
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/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",
|
|
@@ -37,13 +37,15 @@
|
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build": "node '../../ops/scripts/esbuild.js' && yarn run dts",
|
|
39
39
|
"dev": "DEV=true node '../../ops/scripts/esbuild.js' && yarn run dts",
|
|
40
|
-
"dts": "rollup -c",
|
|
40
|
+
"dts": "rollup -c && yarn run prettier 'types/index.d.ts' --write",
|
|
41
41
|
"examples": "node '../../ops/scripts/run-examples.js'",
|
|
42
42
|
"lect": "node '../../ops/lect/lect.js'",
|
|
43
43
|
"letspublish": "yarn publish || :",
|
|
44
44
|
"lint": "eslint . --fix",
|
|
45
45
|
"perf": "node perf/check.js",
|
|
46
46
|
"prepare": "echo 'ready'",
|
|
47
|
+
"prettier": "prettier",
|
|
48
|
+
"prettier:format": "prettier --write '**/*.{ts,tsx,md}' --no-error-on-unmatched-pattern",
|
|
47
49
|
"pretest": "yarn run lect && yarn run build",
|
|
48
50
|
"test": "c8 yarn run unit && yarn run examples && yarn run lint",
|
|
49
51
|
"unit": "uvu test"
|
|
@@ -67,6 +69,6 @@
|
|
|
67
69
|
"various": {}
|
|
68
70
|
},
|
|
69
71
|
"devDependencies": {
|
|
70
|
-
"color-shorthand-hex-to-six-digit": "^4.0.
|
|
72
|
+
"color-shorthand-hex-to-six-digit": "^4.0.11"
|
|
71
73
|
}
|
|
72
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 };
|