New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

attributes-parser

Package Overview
Dependencies
Maintainers
0
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

attributes-parser - npm Package Compare versions

Comparing version 2.2.2 to 2.2.3

62

dist/index.js

@@ -1,4 +0,7 @@

import u from "moo";
import f from "json-loose";
const b = /[ \t\v\f\ufeff]+/, d = /(?:(?![\s\x00\x22\x27\x3E\x2F\x3D\x00-\x1F\x7F-\x9F])[^\s\x00-\x1F\x7F-\x9F\x22\x27\x3E\x2F\x3D])+/, m = /[\.#](?:(?!-?\d)(?:[a-zA-Z0-9\xA0-\uFFFF_-])+)/, h = new RegExp("(?<==)(?:true|false)"), x = new RegExp("(?<==)-?(?:(?:0[xX][\\da-fA-F](?:_?[\\da-fA-F])*|0[oO][0-7](?:_?[0-7])*|0[bB][01](?:_?[01])*)n?|-?0n|-?[1-9](?:_?\\d)*n|(?:(?:0(?!\\d)|0\\d*[89]\\d*|[1-9](?:_?\\d)*)(?:\\.(?:\\d(?:_?\\d)*)?)?|\\.\\d(?:_?\\d)*)(?:[eE][+-]?\\d(?:_?\\d)*)?|-?0[0-7]+)"), g = new RegExp(`(?<==)'(?!.*&[0-9a-zA-Z]+;)[^'\\\\]*(?:\\\\.|\\\\n[^"\\\\]*|&[^0-9a-zA-Z;]*)*'`), p = new RegExp('(?<==)"(?!.*&[0-9a-zA-Z]+;)[^"\\\\]*(?:\\\\.|\\\\n[^"\\\\]*|&[^0-9a-zA-Z;]*)*"'), L = new RegExp("(?<==)[^\"\\s'`=<>\\x00]+");
import c from "moo";
import u from "json-loose";
const f = /[ \t\v\f\ufeff]+/, b = (
// eslint-disable-next-line no-control-regex
/(?:(?![\s\x00\x22\x27\x3E\x2F\x3D\x00-\x1F\x7F-\x9F])[^\s\x00-\x1F\x7F-\x9F\x22\x27\x3E\x2F\x3D])+/
), d = /[.#](?:(?!-?\d)(?:[a-zA-Z0-9\xA0-\uFFFF_-])+)/, m = new RegExp("(?<==)(?:true|false)"), h = new RegExp("(?<==)-?(?:(?:0[xX][\\da-fA-F](?:_?[\\da-fA-F])*|0[oO][0-7](?:_?[0-7])*|0[bB][01](?:_?[01])*)n?|-?0n|-?[1-9](?:_?\\d)*n|(?:(?:0(?!\\d)|0\\d*[89]\\d*|[1-9](?:_?\\d)*)(?:\\.(?:\\d(?:_?\\d)*)?)?|\\.\\d(?:_?\\d)*)(?:[eE][+-]?\\d(?:_?\\d)*)?|-?0[0-7]+)"), x = new RegExp(`(?<==)'(?!.*&[0-9a-zA-Z]+;)[^'\\\\]*(?:\\\\.|\\\\n[^"\\\\]*|&[^0-9a-zA-Z;]*)*'`), g = new RegExp('(?<==)"(?!.*&[0-9a-zA-Z]+;)[^"\\\\]*(?:\\\\.|\\\\n[^"\\\\]*|&[^0-9a-zA-Z;]*)*"'), p = new RegExp("(?<==)[^\"\\s'`=<>\\x00]+");
function i(t) {

@@ -9,18 +12,18 @@ const e = typeof t == "string" && /^(['"]).*?\1$/.test(t) ? (

) : t;
return e.startsWith("[") && e.endsWith("]") || e.startsWith("{") && e.endsWith("}") ? JSON.parse(f(e)) : e;
return e.startsWith("[") && e.endsWith("]") || e.startsWith("{") && e.endsWith("}") ? JSON.parse(u(e)) : e;
}
function A(t) {
function L(t) {
let e = "";
for (const r in t) {
const a = t[r];
for (const s in t) {
const a = t[s];
switch (typeof a) {
case "object":
e += ` ${r}='${JSON.stringify(a)}'`;
e += ` ${s}='${JSON.stringify(a)}'`;
break;
case "string":
e += ` ${r}="${a}"`;
e += ` ${s}="${a}"`;
break;
case "number":
case "boolean":
e += ` ${r}=${a}`;
e += ` ${s}=${a}`;
break;

@@ -31,8 +34,8 @@ }

}
const o = u.states({
const l = c.states({
main: {
WhiteSpace: b,
AttributeShorthand: m,
WhiteSpace: f,
AttributeShorthand: d,
BooleanLiteral: {
match: h,
match: m,
value(t) {

@@ -43,3 +46,3 @@ return t === "true";

NumericLiteral: {
match: x,
match: h,
value(t) {

@@ -51,3 +54,3 @@ const e = Number(t);

SingleQuotedValue: {
match: g,
match: x,
value: i,

@@ -57,3 +60,3 @@ type: () => "StringLiteral"

DoubleQuotedLiteral: {
match: p,
match: g,
value: i,

@@ -63,13 +66,13 @@ type: () => "StringLiteral"

UnquotedLiteral: {
match: L,
match: p,
value: i,
type: () => "StringLiteral"
},
AttributeName: d,
AttributeName: b,
Separator: "="
}
});
function N(t) {
function S(t) {
let e = null;
const r = o.reset(t), a = {};
const s = l.reset(t), a = {};
Object.defineProperties(a, {

@@ -80,3 +83,3 @@ toString: {

configurable: !1,
value: () => A(a)
value: () => L(a)
},

@@ -87,14 +90,13 @@ getTokens: {

configurable: !1,
value: () => Array.from(o.reset(t))
value: () => Array.from(l.reset(t))
}
});
const n = [];
for (const { type: c, value: s } of r)
switch (c) {
for (const { type: o, value: r } of s)
switch (o) {
case "AttributeName":
e = s, a[e] = e;
e = r, a[e] = e;
break;
case "AttributeShorthand":
const l = s[0];
l === "." ? n.push(s.slice(1)) : l === "#" && (a.id = s.slice(1));
r[0] === "." ? n.push(r.slice(1)) : r[0] === "#" && (a.id = r.slice(1));
break;

@@ -104,3 +106,3 @@ case "BooleanLiteral":

case "StringLiteral":
e && (e === "class" && n.push(s), a[e] = s, e = null);
e && (e === "class" && n.push(r), a[e] = r, e = null);
break;

@@ -111,3 +113,3 @@ }

export {
N as default
S as default
};

@@ -1,1 +0,1 @@

(function(s,i){typeof exports=="object"&&typeof module<"u"?module.exports=i(require("moo"),require("json-loose")):typeof define=="function"&&define.amd?define(["moo","json-loose"],i):(s=typeof globalThis<"u"?globalThis:s||self,s.parseAttrs=i(s.moo,s.jsonLoose))})(this,function(s,i){"use strict";const f=/[ \t\v\f\ufeff]+/,d=/(?:(?![\s\x00\x22\x27\x3E\x2F\x3D\x00-\x1F\x7F-\x9F])[^\s\x00-\x1F\x7F-\x9F\x22\x27\x3E\x2F\x3D])+/,b=/[\.#](?:(?!-?\d)(?:[a-zA-Z0-9\xA0-\uFFFF_-])+)/,m=new RegExp("(?<==)(?:true|false)"),h=new RegExp("(?<==)-?(?:(?:0[xX][\\da-fA-F](?:_?[\\da-fA-F])*|0[oO][0-7](?:_?[0-7])*|0[bB][01](?:_?[01])*)n?|-?0n|-?[1-9](?:_?\\d)*n|(?:(?:0(?!\\d)|0\\d*[89]\\d*|[1-9](?:_?\\d)*)(?:\\.(?:\\d(?:_?\\d)*)?)?|\\.\\d(?:_?\\d)*)(?:[eE][+-]?\\d(?:_?\\d)*)?|-?0[0-7]+)"),p=new RegExp(`(?<==)'(?!.*&[0-9a-zA-Z]+;)[^'\\\\]*(?:\\\\.|\\\\n[^"\\\\]*|&[^0-9a-zA-Z;]*)*'`),x=new RegExp('(?<==)"(?!.*&[0-9a-zA-Z]+;)[^"\\\\]*(?:\\\\.|\\\\n[^"\\\\]*|&[^0-9a-zA-Z;]*)*"'),L=new RegExp("(?<==)[^\"\\s'`=<>\\x00]+");function l(t){const e=typeof t=="string"&&/^(['"]).*?\1$/.test(t)?t.slice(1,-1):t;return e.startsWith("[")&&e.endsWith("]")||e.startsWith("{")&&e.endsWith("}")?JSON.parse(i(e)):e}function A(t){let e="";for(const a in t){const r=t[a];switch(typeof r){case"object":e+=` ${a}='${JSON.stringify(r)}'`;break;case"string":e+=` ${a}="${r}"`;break;case"number":case"boolean":e+=` ${a}=${r}`;break}}return e.slice(1)}const u=s.states({main:{WhiteSpace:f,AttributeShorthand:b,BooleanLiteral:{match:m,value(t){return t==="true"}},NumericLiteral:{match:h,value(t){const e=Number(t);return Number.isNaN(e)?Number(t.replace(/_|n$/g,"")):Number(t)}},SingleQuotedValue:{match:p,value:l,type:()=>"StringLiteral"},DoubleQuotedLiteral:{match:x,value:l,type:()=>"StringLiteral"},UnquotedLiteral:{match:L,value:l,type:()=>"StringLiteral"},AttributeName:d,Separator:"="}});function g(t){let e=null;const a=u.reset(t),r={};Object.defineProperties(r,{toString:{writable:!1,enumerable:!1,configurable:!1,value:()=>A(r)},getTokens:{writable:!1,enumerable:!1,configurable:!1,value:()=>Array.from(u.reset(t))}});const o=[];for(const{type:F,value:n}of a)switch(F){case"AttributeName":e=n,r[e]=e;break;case"AttributeShorthand":const c=n[0];c==="."?o.push(n.slice(1)):c==="#"&&(r.id=n.slice(1));break;case"BooleanLiteral":case"NumericLiteral":case"StringLiteral":e&&(e==="class"&&o.push(n),r[e]=n,e=null);break}return o.length&&(r.class=o.join(" ")),r}return g});
(function(a,i){typeof exports=="object"&&typeof module<"u"?module.exports=i(require("moo"),require("json-loose")):typeof define=="function"&&define.amd?define(["moo","json-loose"],i):(a=typeof globalThis<"u"?globalThis:a||self,a.parseAttrs=i(a.moo,a.jsonLoose))})(this,function(a,i){"use strict";const c=/[ \t\v\f\ufeff]+/,f=/(?:(?![\s\x00\x22\x27\x3E\x2F\x3D\x00-\x1F\x7F-\x9F])[^\s\x00-\x1F\x7F-\x9F\x22\x27\x3E\x2F\x3D])+/,d=/[.#](?:(?!-?\d)(?:[a-zA-Z0-9\xA0-\uFFFF_-])+)/,b=new RegExp("(?<==)(?:true|false)"),m=new RegExp("(?<==)-?(?:(?:0[xX][\\da-fA-F](?:_?[\\da-fA-F])*|0[oO][0-7](?:_?[0-7])*|0[bB][01](?:_?[01])*)n?|-?0n|-?[1-9](?:_?\\d)*n|(?:(?:0(?!\\d)|0\\d*[89]\\d*|[1-9](?:_?\\d)*)(?:\\.(?:\\d(?:_?\\d)*)?)?|\\.\\d(?:_?\\d)*)(?:[eE][+-]?\\d(?:_?\\d)*)?|-?0[0-7]+)"),h=new RegExp(`(?<==)'(?!.*&[0-9a-zA-Z]+;)[^'\\\\]*(?:\\\\.|\\\\n[^"\\\\]*|&[^0-9a-zA-Z;]*)*'`),p=new RegExp('(?<==)"(?!.*&[0-9a-zA-Z]+;)[^"\\\\]*(?:\\\\.|\\\\n[^"\\\\]*|&[^0-9a-zA-Z;]*)*"'),x=new RegExp("(?<==)[^\"\\s'`=<>\\x00]+");function l(t){const e=typeof t=="string"&&/^(['"]).*?\1$/.test(t)?t.slice(1,-1):t;return e.startsWith("[")&&e.endsWith("]")||e.startsWith("{")&&e.endsWith("}")?JSON.parse(i(e)):e}function L(t){let e="";for(const n in t){const r=t[n];switch(typeof r){case"object":e+=` ${n}='${JSON.stringify(r)}'`;break;case"string":e+=` ${n}="${r}"`;break;case"number":case"boolean":e+=` ${n}=${r}`;break}}return e.slice(1)}const u=a.states({main:{WhiteSpace:c,AttributeShorthand:d,BooleanLiteral:{match:b,value(t){return t==="true"}},NumericLiteral:{match:m,value(t){const e=Number(t);return Number.isNaN(e)?Number(t.replace(/_|n$/g,"")):Number(t)}},SingleQuotedValue:{match:h,value:l,type:()=>"StringLiteral"},DoubleQuotedLiteral:{match:p,value:l,type:()=>"StringLiteral"},UnquotedLiteral:{match:x,value:l,type:()=>"StringLiteral"},AttributeName:f,Separator:"="}});function A(t){let e=null;const n=u.reset(t),r={};Object.defineProperties(r,{toString:{writable:!1,enumerable:!1,configurable:!1,value:()=>L(r)},getTokens:{writable:!1,enumerable:!1,configurable:!1,value:()=>Array.from(u.reset(t))}});const o=[];for(const{type:g,value:s}of n)switch(g){case"AttributeName":e=s,r[e]=e;break;case"AttributeShorthand":s[0]==="."?o.push(s.slice(1)):s[0]==="#"&&(r.id=s.slice(1));break;case"BooleanLiteral":case"NumericLiteral":case"StringLiteral":e&&(e==="class"&&o.push(s),r[e]=s,e=null);break}return o.length&&(r.class=o.join(" ")),r}return A});
{
"name": "attributes-parser",
"description": "Parsing and tokenizing attributes string",
"version": "2.2.2",
"version": "2.2.3",
"publishConfig": {

@@ -56,3 +56,3 @@ "access": "public"

"dependencies": {
"json-loose": "^1.2.3"
"json-loose": "^1.2.4"
},

@@ -63,4 +63,4 @@ "devDependencies": {

"@types/moo": "0.5.9",
"doogu": "3.2.10",
"semantic-release": "^22.0.12",
"doogu": "4.0.4",
"semantic-release": "^24.1.0",
"vite-plugin-resolve-umd-format": "1.0.0"

@@ -76,3 +76,3 @@ },

},
"prettier": "doogu/prettier.json",
"prettier": "doogu/prettier.config.js",
"release": {

@@ -79,0 +79,0 @@ "extends": "doogu/release.config.js"

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc