string-extract-sass-vars 3.0.10 → 3.0.13

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2010-2021 Roy Revelt and other contributors
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
- This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required:
29
+ This package is [pure ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c). If you're not ready yet, install an older version of this program, 2.1.0 (`npm i string-extract-sass-vars@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-2021 Roy Revelt and other contributors
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.10
4
+ * @version 3.0.13
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.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};
10
+ var h="3.0.13";var y=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 S=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<S;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
+ `.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,y 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.10
4
+ * @version 3.0.13
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,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);})();
10
+ var stringExtractSassVars=(()=>{var c=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames,p=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(p)for(var n of p(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 C=e=>D(c({},"__esModule",{value:!0}),e);var J={};N(J,{defaults:()=>w,extractVars:()=>k,version:()=>x});var v="3.0.13";var x=v,y="\\",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,S=null,i=!1,m=!1,b=!1,h={};for(let s=0;s<$;s++)!i&&o&&e[s]===o&&e[s-1]!==y?o=null:!o&&!i&&e[s-1]!==y&&`'"`.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,(S||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])||(S=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 C(J);})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "string-extract-sass-vars",
3
- "version": "3.0.10",
3
+ "version": "3.0.13",
4
4
  "description": "Parse SASS variables file into a plain object of CSS key-value pairs",
5
5
  "keywords": [
6
6
  "css",
@@ -37,15 +37,18 @@
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
+ "devtest": "c8 yarn run unit && yarn run examples && yarn run lint",
41
+ "dts": "rollup -c && yarn run prettier 'types/index.d.ts' --write",
41
42
  "examples": "node '../../ops/scripts/run-examples.js'",
42
- "lect": "node '../../ops/lect/lect.js'",
43
+ "lect": "node '../../ops/lect/lect.js' && yarn run prettier 'README.md' '.all-contributorsrc' 'rollup.config.js' --write",
43
44
  "letspublish": "yarn publish || :",
44
45
  "lint": "eslint . --fix",
45
46
  "perf": "node perf/check.js",
46
47
  "prepare": "echo 'ready'",
48
+ "prettier": "prettier",
49
+ "prettier:format": "prettier --write '**/*.{ts,tsx,md}' --no-error-on-unmatched-pattern",
47
50
  "pretest": "yarn run lect && yarn run build",
48
- "test": "c8 yarn run unit && yarn run examples && yarn run lint",
51
+ "test": "yarn run devtest",
49
52
  "unit": "uvu test"
50
53
  },
51
54
  "engines": {
@@ -67,6 +70,6 @@
67
70
  "various": {}
68
71
  },
69
72
  "devDependencies": {
70
- "color-shorthand-hex-to-six-digit": "^4.0.10"
73
+ "color-shorthand-hex-to-six-digit": "^4.0.12"
71
74
  }
72
75
  }
package/types/index.d.ts CHANGED
@@ -1,12 +1,15 @@
1
1
  declare const version: string;
2
2
  interface UnknownValueObj {
3
- [key: string]: any;
3
+ [key: string]: any;
4
4
  }
5
5
  interface Opts {
6
- throwIfEmpty?: boolean;
7
- cb?: null | ((varValue: string) => any);
6
+ throwIfEmpty?: boolean;
7
+ cb?: null | ((varValue: string) => any);
8
8
  }
9
9
  declare const defaults: Opts;
10
- declare function extractVars(str: string, originalOpts?: Partial<Opts>): UnknownValueObj;
10
+ declare function extractVars(
11
+ str: string,
12
+ opts?: Partial<Opts>
13
+ ): UnknownValueObj;
11
14
 
12
15
  export { defaults, extractVars, version };