string-extract-sass-vars 3.1.2 → 3.1.4

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 CHANGED
@@ -18,7 +18,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
18
18
 
19
19
  ### BREAKING CHANGES
20
20
 
21
- - programs now are in ES Modules and won't work with Common JS require()
21
+ - programs now are in ES Modules and won't work with Common JS `require()`
22
22
 
23
23
  ## 2.1.0 (2021-05-24)
24
24
 
@@ -34,9 +34,9 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
34
34
 
35
35
  ## 2.0.1 (2021-01-28)
36
36
 
37
- ### Bug Fixes
37
+ ### Fixed
38
38
 
39
- - add testStats to npmignore ([f3c84e9](https://github.com/codsen/codsen/commit/f3c84e95afc5514214312f913692d85b2e12eb29))
39
+ - add `testStats` to npmignore ([f3c84e9](https://github.com/codsen/codsen/commit/f3c84e95afc5514214312f913692d85b2e12eb29))
40
40
 
41
41
  ## 2.0.0 (2021-01-23)
42
42
 
@@ -50,7 +50,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
50
50
 
51
51
  ## 1.3.0 (2020-11-28)
52
52
 
53
- Accidental version bump during migration to sourcehut. Sorry about that.
53
+ Accidental version bump during migration to SourceHut. Sorry about that.
54
54
 
55
55
  ## 1.2.0 (2020-04-26)
56
56
 
@@ -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.1.2
4
+ * @version 3.1.4
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.1.2";var v=h,g="\\",f={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 u={...f,...n};if(u.cb&&typeof u.cb!="function")throw new Error(`string-extract-sass-vars: [THROW_ID_02] resolvedOpts.cb should be function! But it was given as ${JSON.stringify(n,null,4)} (type ${typeof n})`);let p=t.length,o=null,l=null,a=null,i=null,r=null,c=null,s=!1,$=!1,m=!1,b={};for(let e=0;e<p;e++)!s&&r&&t[e]===r&&t[e-1]!==g?r=null:!r&&!s&&t[e-1]!==g&&`'"`.includes(t[e])&&(r=t[e]),$&&`\r
10
+ var h="3.1.4";var v=h,g="\\",f={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 u={...f,...n};if(u.cb&&typeof u.cb!="function")throw new Error(`string-extract-sass-vars: [THROW_ID_02] resolvedOpts.cb should be function! But it was given as ${JSON.stringify(n,null,4)} (type ${typeof n})`);let p=t.length,o=null,l=null,a=null,i=null,r=null,c=null,s=!1,$=!1,m=!1,b={};for(let e=0;e<p;e++)!s&&r&&t[e]===r&&t[e-1]!==g?r=null:!r&&!s&&t[e-1]!==g&&`'"`.includes(t[e])&&(r=t[e]),$&&`\r
11
11
  `.includes(t[e])&&($=!1),!s&&t[e]==="/"&&t[e+1]==="/"&&($=!0),m&&t[e-2]==="*"&&t[e-1]==="/"&&(m=!1),!s&&t[e]==="/"&&t[e+1]==="*"&&(m=!0),s=$||m,!s&&t[e]==="$"&&o===null&&(o=e+1),!s&&l!==null&&!r&&t[e]===";"&&(i=t.slice(`"'`.includes(t[l])?l+1:l,(c||0)+1),/^-?\d*\.?\d*$/.test(i)&&(i=+i),b[a]=u.cb?u.cb(i):i,o=null,l=null,a=null,i=null),!s&&a!==null&&t[e]&&t[e].trim().length&&l===null&&(l=e),!s&&!a&&o!==null&&t[e]===":"&&!r&&(a=t.slice(o,e)),`'"`.includes(t[e])||(c=e);if(!Object.keys(b).length&&u.throwIfEmpty)throw new Error("string-extract-sass-vars: [THROW_ID_03] no keys extracted! (setting resolvedOpts.opts)");return b}export{f 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.1.2
4
+ * @version 3.1.4
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
- "use strict";var stringExtractSassVars=(()=>{var c=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames,S=Object.getOwnPropertySymbols;var d=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable;var f=(e,t,n)=>t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,g=(e,t)=>{for(var n in t||(t={}))d.call(t,n)&&f(e,n,t[n]);if(S)for(var n of S(t))O.call(t,n)&&f(e,n,t[n]);return e};var N=(e,t)=>{for(var n in t)c(e,n,{get:t[n],enumerable:!0})},D=(e,t,n,$)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of V(t))!d.call(e,l)&&l!==n&&c(e,l,{get:()=>t[l],enumerable:!($=E(t,l))||$.enumerable});return e};var x=e=>D(c({},"__esModule",{value:!0}),e);var J={};N(J,{defaults:()=>w,extractVars:()=>k,version:()=>A});var y="3.1.2";var A=y,v="\\",w={throwIfEmpty:!1,cb:null};function k(e,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 n=g(g({},w),t);if(n.cb&&typeof n.cb!="function")throw new Error(`string-extract-sass-vars: [THROW_ID_02] resolvedOpts.cb should be function! But it was given as ${JSON.stringify(t,null,4)} (type ${typeof t})`);let $=e.length,l=null,r=null,a=null,u=null,o=null,p=null,i=!1,m=!1,b=!1,h={};for(let s=0;s<$;s++)!i&&o&&e[s]===o&&e[s-1]!==v?o=null:!o&&!i&&e[s-1]!==v&&`'"`.includes(e[s])&&(o=e[s]),m&&`\r
11
- `.includes(e[s])&&(m=!1),!i&&e[s]==="/"&&e[s+1]==="/"&&(m=!0),b&&e[s-2]==="*"&&e[s-1]==="/"&&(b=!1),!i&&e[s]==="/"&&e[s+1]==="*"&&(b=!0),i=m||b,!i&&e[s]==="$"&&l===null&&(l=s+1),!i&&r!==null&&!o&&e[s]===";"&&(u=e.slice(`"'`.includes(e[r])?r+1:r,(p||0)+1),/^-?\d*\.?\d*$/.test(u)&&(u=+u),h[a]=n.cb?n.cb(u):u,l=null,r=null,a=null,u=null),!i&&a!==null&&e[s]&&e[s].trim().length&&r===null&&(r=s),!i&&!a&&l!==null&&e[s]===":"&&!o&&(a=e.slice(l,s)),`'"`.includes(e[s])||(p=s);if(!Object.keys(h).length&&n.throwIfEmpty)throw new Error("string-extract-sass-vars: [THROW_ID_03] no keys extracted! (setting resolvedOpts.opts)");return h}return x(J);})();
10
+ "use strict";var stringExtractSassVars=(()=>{var c=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames,S=Object.getOwnPropertySymbols;var d=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable;var f=(e,t,n)=>t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,g=(e,t)=>{for(var n in t||(t={}))d.call(t,n)&&f(e,n,t[n]);if(S)for(var n of S(t))O.call(t,n)&&f(e,n,t[n]);return e};var N=(e,t)=>{for(var n in t)c(e,n,{get:t[n],enumerable:!0})},x=(e,t,n,$)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of V(t))!d.call(e,l)&&l!==n&&c(e,l,{get:()=>t[l],enumerable:!($=E(t,l))||$.enumerable});return e};var D=e=>x(c({},"__esModule",{value:!0}),e);var j={};N(j,{defaults:()=>w,extractVars:()=>k,version:()=>A});var y="3.1.4";var A=y,v="\\",w={throwIfEmpty:!1,cb:null};function k(e,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 n=g(g({},w),t);if(n.cb&&typeof n.cb!="function")throw new Error(`string-extract-sass-vars: [THROW_ID_02] resolvedOpts.cb should be function! But it was given as ${JSON.stringify(t,null,4)} (type ${typeof t})`);let $=e.length,l=null,r=null,a=null,u=null,o=null,p=null,i=!1,m=!1,b=!1,h={};for(let s=0;s<$;s++)!i&&o&&e[s]===o&&e[s-1]!==v?o=null:!o&&!i&&e[s-1]!==v&&`'"`.includes(e[s])&&(o=e[s]),m&&`\r
11
+ `.includes(e[s])&&(m=!1),!i&&e[s]==="/"&&e[s+1]==="/"&&(m=!0),b&&e[s-2]==="*"&&e[s-1]==="/"&&(b=!1),!i&&e[s]==="/"&&e[s+1]==="*"&&(b=!0),i=m||b,!i&&e[s]==="$"&&l===null&&(l=s+1),!i&&r!==null&&!o&&e[s]===";"&&(u=e.slice(`"'`.includes(e[r])?r+1:r,(p||0)+1),/^-?\d*\.?\d*$/.test(u)&&(u=+u),h[a]=n.cb?n.cb(u):u,l=null,r=null,a=null,u=null),!i&&a!==null&&e[s]&&e[s].trim().length&&r===null&&(r=s),!i&&!a&&l!==null&&e[s]===":"&&!o&&(a=e.slice(l,s)),`'"`.includes(e[s])||(p=s);if(!Object.keys(h).length&&n.throwIfEmpty)throw new Error("string-extract-sass-vars: [THROW_ID_03] no keys extracted! (setting resolvedOpts.opts)");return h}return D(j);})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "string-extract-sass-vars",
3
- "version": "3.1.2",
3
+ "version": "3.1.4",
4
4
  "description": "Parse SASS variables file into a plain object of CSS key-value pairs",
5
5
  "keywords": [
6
6
  "css",
@@ -43,7 +43,7 @@
43
43
  "examples": "node '../../ops/scripts/run-examples.js'",
44
44
  "lect": "node '../../ops/lect/lect.js' && yarn run prettier 'README.md' '.all-contributorsrc' 'rollup.config.js' --write",
45
45
  "letspublish": "yarn publish || :",
46
- "lint": "eslint . --fix",
46
+ "lint": "eslint . --ext .js --ext .ts --fix",
47
47
  "perf": "node perf/check.js",
48
48
  "prepare": "echo 'ready'",
49
49
  "prettier": "prettier",
@@ -71,6 +71,6 @@
71
71
  "various": {}
72
72
  },
73
73
  "devDependencies": {
74
- "color-shorthand-hex-to-six-digit": "^4.1.2"
74
+ "color-shorthand-hex-to-six-digit": "^4.1.4"
75
75
  }
76
76
  }
@@ -1,32 +0,0 @@
1
- // Quick Take
2
-
3
- import { strict as assert } from "assert";
4
-
5
- import { extractVars } from "../dist/string-extract-sass-vars.esm.js";
6
-
7
- assert.deepEqual(
8
- extractVars(`// all variables are here!!!
9
- // ------------------------------------------
10
- $red: #ff6565; // this is red
11
- // $green: #63ffbd; // no green here
12
- $yellow: #ffff65; // this is yellow
13
- $blue: #08f0fd; // this is blue
14
- $fontfamily: Helvetica, sans-serif;
15
- $border: 1px solid #dedede;
16
- $borderroundedness: 3px;
17
- $customValue1: tralala;
18
- $customValue2: tralala;
19
- // don't mind this comment about #ff6565;
20
- $customValue3: 10;`),
21
- {
22
- red: "#ff6565",
23
- yellow: "#ffff65",
24
- blue: "#08f0fd",
25
- fontfamily: "Helvetica, sans-serif",
26
- border: "1px solid #dedede",
27
- borderroundedness: "3px",
28
- customValue1: "tralala",
29
- customValue2: "tralala",
30
- customValue3: 10,
31
- }
32
- );
@@ -1,16 +0,0 @@
1
- // Convert 3-digit color hex codes to 6-digit
2
-
3
- import { strict as assert } from "assert";
4
- import { conv } from "color-shorthand-hex-to-six-digit";
5
-
6
- import { extractVars } from "../dist/string-extract-sass-vars.esm.js";
7
- // import "color-shorthand-hex-to-six-digit" to convert three-digit colour hex
8
- // codes to six-digit:
9
-
10
- assert.deepEqual(
11
- extractVars("$blue: #2af;", {
12
- throwIfEmpty: true,
13
- cb: (val) => conv(val), // converts hex codes only, bypasses the rest
14
- }),
15
- { blue: "#22aaff" }
16
- );
@@ -1,11 +0,0 @@
1
- // Raises alarm if variables file has been wiped
2
-
3
- import { strict as assert } from "assert";
4
-
5
- import { extractVars } from "../dist/string-extract-sass-vars.esm.js";
6
-
7
- assert.throws(() =>
8
- extractVars("", {
9
- throwIfEmpty: true,
10
- })
11
- );