Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict';
var b = require('ast-types').builders;
function buildTypeImports(type, opts) {
var imports = type.imports;
var others = imports.filter(not(isGraphQL));
var graphql = ['GraphQLObjectType'].concat(imports.filter(isGraphQL));
return opts.es6 ?
es6Import(graphql, others, opts) :
cjsImport(graphql, others, opts);
}
function cjsImport(graphql, others, opts) {
// Require the entity resolver
var declarations = [
b.variableDeclaration('var',
[b.variableDeclarator(
'use strict';
var builders = require('ast-types').builders;
var _ = require('lodash');
// The ast-type builders don't provide a convenient way to set the
// source location of a built node. As a work-around, we wrap each
// builder function with a new function that takes the source location
// as an extra argument and adds it to the new node. The source
// location argument is optional, and is given as the final argument
// when present.
function isLocationNode(node) {
return _.has(node, 'start') && _.has(node, 'end');
}
module.exports = _.mapValues(builders, function(builder) {
return function() {
var args = _.toArray(arguments);
'use strict';
var _ = require('underscore');
var Syntax = require('estraverse').Syntax;
var replace = require('estraverse').replace;
var build = require('ast-types').builders;
var types = require('ast-types').types;
var makeGensym = require('../util').makeGensym;
// filter out:
// -- member expression properties
var genid = null;
var boundVarsStack = null;
var freeVarsStack = null;
var nodeStack = null;
var literalIdentifiers = {
undefined: true,
NaN: true,
"use strict";
var _ = require('underscore');
var esprima = require("esprima");
var escodegen = require("escodegen");
var types = require("ast-types");
var cps = require("../assets/js/cps.js");
var util = require("../assets/js/util.js");
var build = types.builders;
var fooObj = {
bar: 1,
baz: {
blubb: 2,
bla: 3
}
};
var plus = function(k, x, y) {return k(x + y);};
var minus = function(k, x, y) {return k(x - y);};
var times = function(k, x, y) {return k(x * y);};
var and = function(k, x, y) {return k(x && y);};
var plusTwo = function(k, x, y) {return k(x + 2);};
var getTwoK = function(k) {return 2;};
var runCpsTest = function(test, code, expected){
var fs = require('fs'),
b = require('ast-types').builders,
generate = require('escodegen').generate,
Promise = require('./promise'),
astConsts = require('./astConsts'),
parseOptions = require('./parseOptions'),
pathUtils = require('./pathUtils'),
ReplacerMap = require('./replacerMap'),
whenWriteFile = Promise.wrap(fs.writeFile);
exports.transformAST = function (inOptions) {
var options = parseOptions(inOptions),
map = new ReplacerMap(options),
replacer = map.get(options.input);
return map.whenAll().then(function (modules) {
var factoryExpr = astConsts.tmpl.preamble({
deps: options.deps,
'use strict';
var assert = require('assert');
var path = require('path');
var parse = require('esprima').parse;
var replace = require('estraverse').replace;
var generate = require('escodegen').generate;
var build = require('ast-types').builders;
var _ = require('lodash');
var ad = require('./ad').ad;
function isMarkedForGlobalTransform(ast) {
assert.ok(ast.type === 'Program');
var body = ast.body;
if (!(body.length > 0 && isUseStrictExpr(body[0]))) {
throw new Error('Expected program to enable strict mode.');
}
return body.length > 1 && isUseAdExpr(body[1]);
}
function isMarkedForTransform(node) {
return node.body.body.length > 0 && isUseAdExpr(node.body.body[0]);
}
try {
const pathObjectPath = path.get('object')
const { code: memberExpressionValue } = recast.print(pathObjectPath.node)
if (! mapVariableNames.has(memberExpressionValue)) {
this.abort()
}
const { parentPath: pathParentPath } = path
if (! astTypes.namedTypes.AssignmentExpression.check(pathParentPath.node)) {
this.abort()
}
const pathParentPathLeftPath = pathParentPath.get('left')
const pathParentPathRightPath = pathParentPath.get('right')
pathParentPath.replace(
astTypes.builders.callExpression(
astTypes.builders.memberExpression(pathObjectPath.node,
astTypes.builders.identifier('set'),
false),
[
pathParentPathLeftPath.node.property,
pathParentPathRightPath.node
]))
} catch (error) {
if (error instanceof this.AbortRequest) {
return false
} else {
throw error
}
}
this.traverse(path)
}
})
var estemplate = require('estemplate'),
b = require('ast-types').builders,
fs = require('fs');
exports.moduleArgs = [b.identifier('module'), b.identifier('exports')];
exports.tmpl = {};
['external', 'preamble', 'umdWrapper'].forEach(function (name) {
var tmpl = estemplate.compile(fs.readFileSync(__dirname + '/templates/' + name + '.js', 'utf-8'), {
comment: true,
attachComment: true
});
exports.tmpl[name] = function (data) {
data.b = b;
return tmpl(data).body[0].expression;
};
'use strict';
var replace = require('estraverse').replace;
var Syntax = require('estraverse').Syntax;
var build = require('ast-types').builders;
var types = require('ast-types').namedTypes;
var parse = require('esprima').parse;
var fail = require('../syntax').fail;
var inProgram = require('../syntax').inProgram;
var isPrimitive = require('../syntax').isPrimitive;
function thunkify(node) {
return build.functionExpression(
null, [],
build.blockStatement([
build.returnStatement(node)
]), false, false);
}
'use strict';
var camelCase = require('lodash/string/camelCase');
var map = require('lodash/collection/map');
var b = require('ast-types').builders;
var buildVar = require('./variable');
var buildQuery = require('./query');
var buildFieldWrapperFunction = require('./field-wrapper-function');
module.exports = function(data, opts) {
var queryFields = [];
if (opts.relay) {
queryFields.push(b.property(
'init',
b.identifier('node'),
b.identifier('nodeField')
));
} else {
queryFields = map(data.types, function(type) {
return b.property(
'init',