Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-sugar-v-bind-sync

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-sugar-v-bind-sync - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

lib/index.js.map

3

lib/index.js

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

"use strict";var e=require("@babel/plugin-syntax-jsx"),n=require("camelcase");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=t(e),o=t(n);module.exports=function(e){const n=e.types;function t(e){return n.ExpressionStatement(n.AssignmentExpression("=",e,n.Identifier("$$val")))}const s=/(.*)\_sync/;return{inherits:r.default,visitor:{JSXOpeningElement(e){const r={};e.get("attributes").forEach((i=>{const a=i.node.name.name.match(s);if(a){const s=a[1];let u;if(i.node.name.name=s,i.traverse({JSXExpressionContainer(e){u=e.node.expression}}),!n.isMemberExpression(u))return void console.error(`You should use MemberExpression with sync modifier, prop [${s}] on node [${e.node.name.name}]`);!function(e,t,r){e[t]=n.ArrowFunctionExpression([n.Identifier("$$val")],n.BlockStatement(r))}(r,`update:${o.default(s)}`,[t(u)])}})),0!==Object.entries(r).length&&e.node.attributes.push(n.JSXSpreadAttribute(function(e={}){return n.objectExpression(Object.keys(e).map((t=>n.objectProperty(n.stringLiteral(t),e[t]))))}(r)))}}}};
"use strict";var e=require("@babel/plugin-syntax-jsx"),t=require("camelcase");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=r(e),i=r(t);const s=["on"],o=/(.*)\_sync/;module.exports=e=>{const t=e.types;function r(e){return t.ExpressionStatement(t.AssignmentExpression("=",e,t.Identifier("$$val")))}function a(e,r=[]){const n=e.get("name");let i,a;if(a=t.isJSXNamespacedName(n)?`${n.get("namespace.name").node}:${n.get("name.name").node}`:n.get("name").node,s.includes(a)&&t.isJSXExpressionContainer(e.get("value")))return t.JSXSpreadAttribute(t.objectExpression([t.objectProperty(t.stringLiteral(a),e.get("value").node.expression)]));i=s.find((e=>a.startsWith(e))),a=a.replace(new RegExp(`^${i}-?`),""),a=a[0].toLowerCase()+a.substr(1);const u=e.get("value");if(!t.isJSXExpressionContainer(u))throw new Error(`getAttribute (attribute value): should be an JSXExpressionContainer but got ${u.type}`);const p=u.get("expression").node,c=a.match(o);if(null!=c){if(!t.isMemberExpression(p)){const t=e.get("parent").get("name.name").node;throw new Error(`getAttribute (attribute value): You should use MemberExpression with sync modifier, prop [${prop}] on node [${t}]`)}return{prop:c[1],value:p}}i&&(!function(e,r,n){if(e[r]){let i=!1;t.isObjectProperty(n)&&"on"===r&&(e[r].properties.forEach((e=>{t.isObjectProperty(e)&&e.key.value===n.key.value&&(t.isArrayExpression(e.value)?e.value.elements.push(n.value):e.value=t.arrayExpression([e.value,n.value]),i=!0)})),i||e[r].properties.push(n))}else e[r]=t.objectExpression([n])}(r,i,t.objectProperty(t.stringLiteral(a),p)),e.remove())}function u(e){const r={};return e.forEach((e=>{a(e,r)})),!!Object.entries(r).length&&function(e){return t.objectExpression(Object.entries(e).map((([e,r])=>t.objectProperty(t.stringLiteral(e),r))))}(r)}return{inherits:n.default,visitor:{JSXAttribute(e){const n=a(e);if(n&&!t.isJSXSpreadAttribute(n)){const{prop:o,value:a}=n;e.replaceWith(t.jSXAttribute(t.jSXIdentifier(o),t.jSXExpressionContainer(a))),e.parent.attributes.push(function(e,r){return t.jSXAttribute(t.jSXIdentifier(e),t.jSXExpressionContainer(r))}(`onUpdate:${i.default(o)}`,(s=a,t.ArrowFunctionExpression([t.Identifier("$$val")],t.BlockStatement([r(s)])))))}var s},JSXOpeningElement:{exit(e){const r=u(e.get("attributes"));r&&e.node.attributes.push(t.JSXSpreadAttribute(r))}}}}};
//# sourceMappingURL=index.js.map
{
"name": "babel-sugar-v-bind-sync",
"version": "0.2.0",
"version": "0.2.1",
"description": "Babel syntactic sugar for v-bind sync modifier support in Vue JSX",

@@ -5,0 +5,0 @@ "keywords": [

@@ -27,4 +27,5 @@ import babel from '@rollup/plugin-babel';

format: 'cjs',
sourcemap: true,
},
],
};
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