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

ast-types

Package Overview
Dependencies
Maintainers
1
Versions
172
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ast-types - npm Package Compare versions

Comparing version 0.15.2 to 0.16.0

lib/def/babel-core.d.ts

2

lib/equiv.d.ts

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

import { Fork } from "../types";
import { Fork } from "./types";
export default function (fork: Fork): {

@@ -3,0 +3,0 @@ (a: any, b: any, problemPath?: any): boolean;

@@ -1,5 +0,6 @@

"use strict";;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var types_1 = (0, tslib_1.__importDefault)(require("./types"));
var shared_1 = require("./shared");
var types_1 = tslib_1.__importDefault(require("./types"));
function default_1(fork) {

@@ -154,2 +155,4 @@ var types = fork.use(types_1.default);

exports.default = default_1;
module.exports = exports["default"];
;
(0, shared_1.maybeSetModuleExports)(function () { return module; });
//# sourceMappingURL=equiv.js.map

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

import { Fork } from "../types";
import { ASTNode } from "./types";
import { ASTNode, Fork } from "./types";
import { Path } from "./path";

@@ -4,0 +3,0 @@ import { Scope } from "./scope";

@@ -1,7 +0,8 @@

"use strict";;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var types_1 = (0, tslib_1.__importDefault)(require("./types"));
var path_1 = (0, tslib_1.__importDefault)(require("./path"));
var scope_1 = (0, tslib_1.__importDefault)(require("./scope"));
var types_1 = tslib_1.__importDefault(require("./types"));
var path_1 = tslib_1.__importDefault(require("./path"));
var scope_1 = tslib_1.__importDefault(require("./scope"));
var shared_1 = require("./shared");
function nodePathPlugin(fork) {

@@ -411,2 +412,4 @@ var types = fork.use(types_1.default);

exports.default = nodePathPlugin;
module.exports = exports["default"];
;
(0, shared_1.maybeSetModuleExports)(function () { return module; });
//# sourceMappingURL=node-path.js.map

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

import { Fork, Omit } from "../types";
import { ASTNode } from "./types";
import { ASTNode, Fork, Omit } from "./types";
import { NodePath } from "./node-path";

@@ -25,3 +24,3 @@ export interface PathVisitor {

fromMethodsObject(methods?: any): Visitor;
visit<M = {}>(node: ASTNode, methods?: import("../gen/visitor").Visitor<M>): any;
visit<M = {}>(node: ASTNode, methods?: import("./gen/visitor").Visitor<M>): any;
}

@@ -28,0 +27,0 @@ export interface PathVisitorConstructor extends PathVisitorStatics {

@@ -1,6 +0,7 @@

"use strict";;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var types_1 = (0, tslib_1.__importDefault)(require("./types"));
var node_path_1 = (0, tslib_1.__importDefault)(require("./node-path"));
var types_1 = tslib_1.__importDefault(require("./types"));
var node_path_1 = tslib_1.__importDefault(require("./node-path"));
var shared_1 = require("./shared");
var hasOwn = Object.prototype.hasOwnProperty;

@@ -343,2 +344,4 @@ function pathVisitorPlugin(fork) {

exports.default = pathVisitorPlugin;
module.exports = exports["default"];
;
(0, shared_1.maybeSetModuleExports)(function () { return module; });
//# sourceMappingURL=path-visitor.js.map

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

import { Fork } from "../types";
import { ASTNode } from "./types";
import { ASTNode, Fork } from "./types";
export interface Path<V = any> {

@@ -4,0 +3,0 @@ value: V;

@@ -1,5 +0,6 @@

"use strict";;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var types_1 = (0, tslib_1.__importDefault)(require("./types"));
var shared_1 = require("./shared");
var types_1 = tslib_1.__importDefault(require("./types"));
var Op = Object.prototype;

@@ -331,2 +332,4 @@ var hasOwn = Op.hasOwnProperty;

exports.default = pathPlugin;
module.exports = exports["default"];
;
(0, shared_1.maybeSetModuleExports)(function () { return module; });
//# sourceMappingURL=path.js.map

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

import { Fork } from "../types";
import { NodePath } from "./node-path";
import { Fork } from "./types";
export interface Scope {

@@ -4,0 +4,0 @@ path: NodePath;

@@ -1,5 +0,6 @@

"use strict";;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var types_1 = (0, tslib_1.__importDefault)(require("./types"));
var shared_1 = require("./shared");
var types_1 = tslib_1.__importDefault(require("./types"));
var hasOwn = Object.prototype.hasOwnProperty;

@@ -355,2 +356,4 @@ function scopePlugin(fork) {

exports.default = scopePlugin;
module.exports = exports["default"];
;
(0, shared_1.maybeSetModuleExports)(function () { return module; });
//# sourceMappingURL=scope.js.map

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

import { Fork } from "../types";
import { Fork } from "./types";
export default function (fork: Fork): {

@@ -14,1 +14,9 @@ geq: (than: any) => import("./types").Type<unknown>;

};
interface NodeModule {
exports: {
default?: any;
__esModule?: boolean;
};
}
export declare function maybeSetModuleExports(moduleGetter: () => NodeModule): void;
export {};

@@ -1,5 +0,6 @@

"use strict";;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.maybeSetModuleExports = void 0;
var tslib_1 = require("tslib");
var types_1 = (0, tslib_1.__importDefault)(require("./types"));
var types_1 = tslib_1.__importDefault(require("./types"));
function default_1(fork) {

@@ -47,2 +48,45 @@ var types = fork.use(types_1.default);

exports.default = default_1;
module.exports = exports["default"];
;
// This function accepts a getter function that should return an object
// conforming to the NodeModule interface above. Typically, this means calling
// maybeSetModuleExports(() => module) at the very end of any module that has a
// default export, so the default export value can replace module.exports and
// thus CommonJS consumers can continue to rely on require("./that/module")
// returning the default-exported value, rather than always returning an exports
// object with a default property equal to that value. This function should help
// preserve backwards compatibility for CommonJS consumers, as a replacement for
// the ts-add-module-exports package.
function maybeSetModuleExports(moduleGetter) {
try {
var nodeModule = moduleGetter();
var originalExports = nodeModule.exports;
var defaultExport = originalExports["default"];
}
catch (_a) {
// It's normal/acceptable for this code to throw a ReferenceError due to
// the moduleGetter function attempting to access a non-existent global
// `module` variable. That's the reason we use a getter function here:
// so the calling code doesn't have to do its own typeof module ===
// "object" checking (because it's always safe to pass `() => module` as
// an argument, even when `module` is not defined in the calling scope).
return;
}
if (defaultExport &&
defaultExport !== originalExports &&
typeof originalExports === "object") {
// Make all properties found in originalExports properties of the
// default export, including the default property itself, so that
// require(nodeModule.id).default === require(nodeModule.id).
Object.assign(defaultExport, originalExports, { "default": defaultExport });
// Object.assign only transfers enumerable properties, and
// __esModule is (and should remain) non-enumerable.
if (originalExports.__esModule) {
Object.defineProperty(defaultExport, "__esModule", { value: true });
}
// This line allows require(nodeModule.id) === defaultExport, rather
// than (only) require(nodeModule.id).default === defaultExport.
nodeModule.exports = defaultExport;
}
}
exports.maybeSetModuleExports = maybeSetModuleExports;
//# sourceMappingURL=shared.js.map

@@ -1,4 +0,8 @@

import { Fork } from "../types";
declare type Deep = boolean | ((type: Type<any>, value: any) => void);
export declare type Type<T> = ArrayType<T> | IdentityType<T> | ObjectType<T> | OrType<T> | PredicateType<T>;
export type Fork = {
use<T>(plugin: Plugin<T>): T;
};
export type Plugin<T> = (fork: Fork) => T;
export type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
type Deep = boolean | ((type: Type<any>, value: any) => void);
export type Type<T> = ArrayType<T> | IdentityType<T> | ObjectType<T> | OrType<T> | PredicateType<T>;
export interface AnyType {

@@ -90,3 +94,3 @@ toString(): string;

}
declare type FieldType<T> = Field<T>;
type FieldType<T> = Field<T>;
export { FieldType as Field };

@@ -105,3 +109,3 @@ export interface ASTNode {

or(...types: any[]): Type<any>;
from<T>(value: any, name?: string | undefined): Type<T>;
from<T>(value: any, name?: string): Type<T>;
def(typeName: string): Def;

@@ -129,7 +133,7 @@ hasDef(typeName: string): boolean;

};
builders: import("../gen/builders").builders;
defineMethod: (name: any, func?: Function | undefined) => Function;
builders: import("./gen/builders").builders;
defineMethod: (name: any, func?: Function) => Function;
getBuilderName: (typeName: any) => any;
getStatementBuilderName: (typeName: any) => any;
namedTypes: import("../gen/namedTypes").NamedTypes;
namedTypes: import("./gen/namedTypes").NamedTypes;
getFieldNames: (object: any) => string[];

@@ -136,0 +140,0 @@ getFieldValue: (object: any, fieldName: any) => any;

@@ -5,2 +5,3 @@ "use strict";

var tslib_1 = require("tslib");
var shared_1 = require("./shared");
var Op = Object.prototype;

@@ -26,3 +27,3 @@ var objToStr = Op.toString;

var ArrayType = /** @class */ (function (_super) {
(0, tslib_1.__extends)(ArrayType, _super);
tslib_1.__extends(ArrayType, _super);
function ArrayType(elemType) {

@@ -44,3 +45,3 @@ var _this = _super.call(this) || this;

var IdentityType = /** @class */ (function (_super) {
(0, tslib_1.__extends)(IdentityType, _super);
tslib_1.__extends(IdentityType, _super);
function IdentityType(value) {

@@ -65,3 +66,3 @@ var _this = _super.call(this) || this;

var ObjectType = /** @class */ (function (_super) {
(0, tslib_1.__extends)(ObjectType, _super);
tslib_1.__extends(ObjectType, _super);
function ObjectType(fields) {

@@ -85,3 +86,3 @@ var _this = _super.call(this) || this;

var OrType = /** @class */ (function (_super) {
(0, tslib_1.__extends)(OrType, _super);
tslib_1.__extends(OrType, _super);
function OrType(types) {

@@ -97,5 +98,9 @@ var _this = _super.call(this) || this;

OrType.prototype.check = function (value, deep) {
return this.types.some(function (type) {
return type.check(value, deep);
});
if (this.types.some(function (type) { return type.check(value, !!deep); })) {
return true;
}
if (typeof deep === "function") {
deep(this, value);
}
return false;
};

@@ -105,3 +110,3 @@ return OrType;

var PredicateType = /** @class */ (function (_super) {
(0, tslib_1.__extends)(PredicateType, _super);
tslib_1.__extends(PredicateType, _super);
function PredicateType(name, predicate) {

@@ -359,3 +364,3 @@ var _this = _super.call(this) || this;

var DefImpl = /** @class */ (function (_super) {
(0, tslib_1.__extends)(DefImpl, _super);
tslib_1.__extends(DefImpl, _super);
function DefImpl(typeName) {

@@ -793,1 +798,3 @@ var _this = _super.call(this, new PredicateType(typeName, function (value, deep) { return _this.check(value, deep); }), typeName) || this;

;
(0, shared_1.maybeSetModuleExports)(function () { return module; });
//# sourceMappingURL=types.js.map
{
"author": "Ben Newman <bn@cs.stanford.edu>",
"name": "ast-types",
"version": "0.15.2",
"version": "0.16.0",
"description": "Esprima-compatible implementation of the Mozilla JS Parser API",

@@ -28,12 +28,17 @@ "keywords": [

"license": "MIT",
"main": "main.js",
"types": "main.d.ts",
"main": "lib/main.js",
"types": "lib/main.d.ts",
"exports": {
".": "./lib/main.js",
"./lib/*": "./lib/*.js",
"./lib/*.js": "./lib/*.js",
"./*": "./lib/*.js",
"./*.js": "./lib/*.js"
},
"scripts": {
"gen": "ts-node --transpile-only script/gen-types.ts",
"mocha": "test/run.sh",
"test": "npm run gen && npm run build && npm run mocha",
"clean": "ts-emit-clean",
"build": "tsc && ts-add-module-exports",
"prepare": "npm run clean && npm run gen && npm run build",
"postpack": "npm run clean"
"test": "npm run gen && npm run build && script/run-tests.sh",
"clean": "rimraf lib/",
"build": "tsc",
"prepare": "npm run clean && npm run build"
},

@@ -44,20 +49,18 @@ "dependencies": {

"devDependencies": {
"@babel/parser": "7.16.4",
"@babel/types": "7.16.0",
"@babel/parser": "7.20.5",
"@babel/types": "7.20.5",
"@types/esprima": "4.0.3",
"@types/glob": "7.2.0",
"@types/glob": "8.0.0",
"@types/mocha": "9.0.0",
"@types/node": "16.11.10",
"espree": "9.1.0",
"espree": "9.4.1",
"esprima": "4.0.1",
"esprima-fb": "15001.1001.0-dev-harmony-fb",
"flow-parser": "0.166.0",
"glob": "7.2.0",
"flow-parser": "0.195.0",
"glob": "8.0.3",
"mocha": "^9.1.3",
"recast": "0.20.5",
"recast": "^0.23.0",
"reify": "0.20.12",
"ts-add-module-exports": "1.0.0",
"ts-emit-clean": "1.0.0",
"ts-node": "10.4.0",
"typescript": "4.5.2"
"rimraf": "3.0.2",
"ts-node": "10.9.1",
"typescript": "4.9.4"
},

@@ -64,0 +67,0 @@ "engines": {

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