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

ast-ts

Package Overview
Dependencies
Maintainers
10
Versions
206
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ast-ts - npm Package Compare versions

Comparing version 1.2.9 to 1.2.10

30

package.json
{
"name": "ast-ts",
"version": "1.2.9",
"version": "1.2.10",
"description": "ast representation and transform function with typescript definitions",

@@ -8,3 +8,3 @@ "main": "src/index.js",

"scripts": {
"test": "MOCHA_FILE=./output/junit.xml nyc mocha --reporter mocha-multi --reporter-options spec=-,mocha-junit-reporter=-",
"test": "MOCHA_FILE=./output/junit.xml nyc mocha --forbid-only --reporter mocha-multi --reporter-options spec=-,mocha-junit-reporter=-",
"test:mocha": "mocha",

@@ -15,3 +15,4 @@ "test:watch": "mocha --watch",

"lintfix": "tslint -p . --fix",
"lint": "tslint -p ."
"lint": "tslint -p .",
"report": "nyc report --reporter=text-lcov > coverage.lcov && codecov"
},

@@ -23,15 +24,16 @@ "files": [

"author": "",
"license": "MIT",
"license": "",
"peerDependencies": {
"@stridespark/model-core": "^5.0.0 || ^6.0.0 || ^7.0.0"
"@stridespark/model-core": "^13.0.0",
"@stridespark/commonwealth": "1.7.0"
},
"devDependencies": {
"@stridespark/model-core": "^7.4.2",
"@types/chai": "^3.4.34",
"@stridespark/model-core": "^13.0.0",
"@types/chai": "^4.0.10",
"@types/mocha": "^2.2.33",
"@types/node": "^8.0.16",
"chai": "3.5.0",
"codecov": "^2.3.0",
"chai": "4.1.2",
"codecov": "^3.0.0",
"istanbul": "0.4.5",
"mocha": "^3.4.2",
"mocha": "^4.0.1",
"mocha-junit-reporter": "^1.13.0",

@@ -44,3 +46,3 @@ "mocha-lcov-reporter": "^1.3.0",

"publish": "0.6.0",
"source-map-support": "^0.4.14",
"source-map-support": "^0.5.0",
"tslint": "^5.7.0",

@@ -50,3 +52,4 @@ "tslint-config-prettier": "^1.5.0",

"tslint-stridespark": "^2.0.3",
"typescript": "^2.4.2"
"typescript": "^2.4.2",
"@stridespark/commonwealth": "1.7.0"
},

@@ -61,4 +64,3 @@ "nyc": {

},
"repository": "StrideSpark/ast-ts",
"dependencies": {}
"repository": "StrideSpark/ast-ts"
}

@@ -1,14 +0,8 @@

# ast-ts
# mandrill-client
## installation
```bash
npm install ast-ts
```
## usage
```javascript
var ast-ts = require('ast-ts');
```
## Testing
### Running Tests
- Note that these tests can only be run locally
- Before submitting a PR, please run the following commands to check correctness and upload a coverage report:
- npm run test-local
- npm run report

@@ -16,7 +16,5 @@ import { ASTContent, ASTNode } from '@stridespark/model-core';

/**
* Reduce an ASTNode to a 'T' by bottoms-up applying the TransformFunction
* specified by tag in the TransformMap
* Applies the TransformFunction listen in 'default' otherwise if it exists
*/
export declare function transformSome<T>(node: ASTNode, transformMap: TransformMap<T>): T;
* Replaces any nodes (and their children) that match toRemove with toReplace. Will modify node.
**/
export declare function replaceNode(node: ASTContent, toRemove: (node: ASTContent) => boolean, toReplace: ASTNode): ASTContent;
/**

@@ -23,0 +21,0 @@ * Return array of nodes (and their children) that match predicate.

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const commonwealth_1 = require("@stridespark/commonwealth");
function n(tag, content) {
return {
tag: tag,
content: content,
tag,
content,
};

@@ -20,4 +21,4 @@ }

// first transform content
var transformedContent = node.content &&
node.content.map(function (child) {
const transformedContent = node.content &&
node.content.map(child => {
if (isASTNode(child)) {

@@ -29,3 +30,3 @@ return transform(child, transformMap);

// then possibly transform this
var transformer = transformMap[node.tag];
const transformer = transformMap[node.tag] || transformMap['default'];
if (transformer) {

@@ -38,27 +39,15 @@ return transformer(transformedContent);

/**
* Reduce an ASTNode to a 'T' by bottoms-up applying the TransformFunction
* specified by tag in the TransformMap
* Applies the TransformFunction listen in 'default' otherwise if it exists
*/
function transformSome(node, transformMap) {
// first transform content
var transformedContent = node.content &&
node.content.map(function (child) {
if (isASTNode(child)) {
return transform(child, transformMap);
}
return child;
});
// then possibly transform this
var transformer = transformMap[node.tag];
if (transformer) {
return transformer(transformedContent);
* Replaces any nodes (and their children) that match toRemove with toReplace. Will modify node.
**/
function replaceNode(node, toRemove, toReplace) {
if (toRemove(node)) {
return toReplace;
}
var defaultTransformer = transformMap['default'];
if (defaultTransformer) {
return defaultTransformer(transformedContent);
if (typeof node === 'string' || node.content == undefined) {
return node;
}
throw new Error('no transform found for ' + node.tag);
const newContents = commonwealth_1.mapDef(node.content, (n) => replaceNode(n, toRemove, toReplace));
return Object.assign({}, node, { content: newContents || [] });
}
exports.transformSome = transformSome;
exports.replaceNode = replaceNode;
/**

@@ -75,5 +64,5 @@ * Return array of nodes (and their children) that match predicate.

}
var matchingContent = node.content
.map(function (m) { return filter(m, predicate); })
.reduce(function (a, b) { return a.concat(b); }, []);
const matchingContent = node.content
.map((m) => filter(m, predicate))
.reduce((a, b) => a.concat(b), []);
if (matchingContent) {

@@ -80,0 +69,0 @@ return matchingContent;

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