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 4.0.1 to 4.1.0

35

lib/is.js

@@ -10,2 +10,4 @@ 'use strict';

const isStr = (a) => typeof a === 'string';
const ANY_OBJECT = '__object';

@@ -17,3 +19,30 @@ const ANY_ARRAY = '__array';

const BODY = '__body';
const ANY = '__';
const ALL = [
ANY_OBJECT,
ANY_ARRAY,
ARGS,
LINKED_NODE,
IMPORTS,
BODY,
ANY,
];
module.exports.is = (str, array = ALL) => {
for (const item of array) {
if (check(str, item))
return true;
}
return false;
};
function check(str, item) {
if (isStr(item))
return str === item;
return item.test(str);
}
module.exports.isNameStr = (a) => LINKED_NODE.test(a);

@@ -23,2 +52,4 @@ module.exports.isImportsStr = (a) => a === IMPORTS;

module.exports.isObjectStr = (a) => a === ANY_OBJECT;
module.exports.isArrayStr = (a) => a === ANY_ARRAY;
module.exports.isAnyStr = (a) => a === ANY;

@@ -42,4 +73,4 @@ const isBody = (a) => isIdentifier(a, {

module.exports.isStr = (a) => typeof a === 'string';
module.exports.isAny = (a) => isIdentifier(a, {name: '__'});
module.exports.isAnyLiteral = (a, b) => isLiteral(b, {value: '__'}) && isEqualType(a, b);
module.exports.isAny = (a) => isIdentifier(a, {name: ANY});
module.exports.isAnyLiteral = (a, b) => isLiteral(b, {value: ANY}) && isEqualType(a, b);
module.exports.isArgs = (a) => {

@@ -46,0 +77,0 @@ const b = !isArray(a) ? a : a[0];

7

lib/vars.js

@@ -11,6 +11,6 @@ 'use strict';

const {
is,
isNameStr,
isArgsStr,
isImportsStr,
isArgsStr,
isObjectStr,
} = require('./is');

@@ -50,3 +50,3 @@

if (!isNameStr(name) && !isImportsStr(name) && !isArgsStr(name) && !isObjectStr(name))
if (!is(name))
return;

@@ -117,1 +117,2 @@

}
{
"name": "@putout/compare",
"version": "4.0.1",
"version": "4.1.0",
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",

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

@@ -19,5 +19,24 @@ # putout-compare [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL]

### Compare (node, baseNode)
### getTemplateValues(node, template)
- `node` - `AST-node` or `code` that will be generated;
- `template` - template string with template variables;
```js
const {operator} = require('putout');
const {template} = operator;
const node = template.ast('const [] = a');
getTemplateValues(node, 'const __array = array');
// returns
{
__array: {
type: 'ArrayPattern',
...etc
}
}
```
### compare (node, baseNode)
- `node` - `AST-node` or `code` that will be generated;
- `baseNode` `AST-node` with support of `template variables`.

@@ -24,0 +43,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