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

@putout/compare

Package Overview
Dependencies
Maintainers
1
Versions
133
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@putout/compare - npm Package Compare versions

Comparing version 3.4.0 to 3.5.0

16

lib/compare.js

@@ -16,3 +16,4 @@ 'use strict';

isAnyLiteral,
isAnyArgs,
isArgs,
isImports,
isStr,

@@ -25,2 +26,5 @@ isPath,

parseTemplate,
isNameStr,
isArgsStr,
isImportsStr,
} = require('./is');

@@ -54,2 +58,6 @@

module.exports.isName = isNameStr;
module.exports.isImports = isImportsStr;
module.exports.isArgs = isArgsStr;
function compare(path, base) {

@@ -174,5 +182,8 @@ const node = parseNode(path);

if (isAnyArgs(value))
if (isImports(value))
return true;
if (isArgs(value))
return true;
if (isObject(value)) {

@@ -190,1 +201,2 @@ add(nodeValue, value);

}

@@ -7,2 +7,3 @@ 'use strict';

isLiteral,
isImportDefaultSpecifier,
} = require('@babel/types');

@@ -12,5 +13,10 @@

const ANY_ARRAY = '__array';
const ANY_ARGS = '__args';
const ARGS = '__args';
const LINKED_NODE = /^__[a-z]$/;
const IMPORTS = '__imports';
module.exports.isNameStr = (a) => LINKED_NODE.test(a);
module.exports.isImportsStr = (a) => a === IMPORTS;
module.exports.isArgsStr = (a) => a === ARGS;
const isAnyObject = (a) => isIdentifier(a, {

@@ -31,7 +37,7 @@ name: ANY_OBJECT,

module.exports.isAnyLiteral = (a, b) => isLiteral(b, {value: '__'}) && isEqualType(a, b);
module.exports.isAnyArgs = (a) => {
module.exports.isArgs = (a) => {
const b = !isArray(a) ? a : a[0];
return isIdentifier(b, {
name: ANY_ARGS,
name: ARGS,
});

@@ -63,2 +69,13 @@ };

module.exports.isImports = (a) => {
const b = !isArray(a) ? a : a[0];
if (!isImportDefaultSpecifier(b))
return false;
return isIdentifier(b.local, {
name: IMPORTS,
});
};
const __OBJECT_TYPE = 'ObjectPattern|ObjectExpression';

@@ -65,0 +82,0 @@ const __ARRAY_TYPE = 'ArrayPattern|ArrayExpression';

2

package.json
{
"name": "@putout/compare",
"version": "3.4.0",
"version": "3.5.0",
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",

@@ -5,0 +5,0 @@ "description": "compare ast-nodes",

@@ -73,2 +73,10 @@ # putout-compare [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL]

##### __imports
Any count of `imports`:
```js
compare('import React, {Component} from "react"', 'import __imports from "react"');
```
##### "__"

@@ -81,2 +89,9 @@ Any string literal.

##### __a
Linked literal
```js
compare('const __a = "hello"', 'const __a = "hello"');
```
##### "__a"

@@ -89,2 +104,3 @@ Linked string literal.

## License

@@ -91,0 +107,0 @@

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