Module API 
https://github.com/frictionlessdata/datapackage-js#infer
181226
async function infer(pattern, {basePath}={}) {
  const dataPackage = await Package.load({}, {basePath})
  const descriptor = await dataPackage.infer(pattern)
  return descriptor
}
561239
function js2dtCLI (jsonFile, ramlTypeName) {
  const jsonData = fs.readFileSync(jsonFile).toString()

  if (ramlTypeName != null) {
    const raml = js2dt.js2dt(jsonData, ramlTypeName)
    return `#%RAML 1.0 Library\n${yaml.safeDump({ types: raml }, { 'noRefs': true })}`
  } else {
    const typeName = 'this__should__be__the__only__type'
    const raml = js2dt.js2dt(jsonData, typeName)

    const keys = Object.keys(raml)
    if (keys.length !== 1 || !keys.includes(typeName)) {
      throw new Error(`There is more than one type (${JSON.stringify(keys)}), please specify a name for the raml library`)
    }

    return `#%RAML 1.0 DataType\n${yaml.safeDump(raml[typeName], { 'noRefs': true })}`
  }
}
127504
function getInfoFromNodeModules (presetName) {
  debug('get preset info from node_modules')

  const baseDir = getBaseDir()
  const packagePath = path.join(baseDir, 'node_modules', presetName, 'package.json')

  if (!fs.existsSync(packagePath)) {
    debug('package not exist')
    return null
  }

  debug(`package.json path: ${packagePath}`)

  const packageInfo = require(packagePath)

  debug('package info: %o', packageInfo)

  return {
    name: presetName,
    version: packageInfo.version,
    registryUrl: getRegistryUrl(packageInfo._resolved)
  }
}
293258
function loadInfo() {
    try {
      var data = fs.readFileSync(__rootdir + '/package.json', { encoding: 'utf8' });
      var tmp = JSON.parse(data);
      appPackage = {
        name: tmp.name || null,
        version: tmp.version || 1
      }
    } catch(e) {
      return; // nothing to do.
    }
  }
1330094
function mapByDepth(rootPackage) {
    var depth = 0
      , allDeps = {}
      , superDepsList = {}
      ;

    function traverseDeps(childPackage) {
      depth += 1;

      childPackage.dependencyTree = childPackage.dependencyTree || {};
      Object.keys(childPackage.dependencyTree).forEach(function (depName) {
        var childDeps = (childPackage.dependencyTree[depName] || {}) || {}
          ;

        if (superDepsList[depName]) {
          // a dependency can't (meaning shouldn't) have a path in which it depends on itself
          // this kind of resolution isn't as important as it once was
          // since the modules can be loaded out-of-order
          return;
        }

        superDepsList[depName] = true;

        allDeps[depth] = allDeps[depth] || [];
        allDeps[depth].push(depName);

        if (childDeps) {
          traverseDeps(childDeps);
        }

        superDepsList[depName] = false;
      });

      depth -= 1;
    }

    traverseDeps(rootPackage);

    return allDeps;
  }
1143346
function pullDataFromEndp(opts, catalog, model, cb) {
  var myopts = extend({}, opts);
  myopts.path = APIM_CATALOG_ENDP + '/' + catalog.cat + model.endp + '?' + // filter parms
      APIM_CLIENT_ID_EQ + opts.clientid + '&' + APIM_TYPE_EQ + APIM_TYPE_FILTER;
  myopts.prefix = model.prefix + catalog.org + '-' + catalog.cat + '-';
  myopts.suffix = '.json';

  fetch(myopts, function(err, result) {
    if (err) {
      cb(err);
    } else if (typeof result === 'object') {
      response[model.name].push(result.file);
      cb();
    } else {
      var error = new Error('Unexpected type returned from ' + model.name + ' fetch');
      cb(error);
    }
  });
}
940609
function getPackageName(content, pluginLookup, identifierPath) {
  let memberPath = identifierPath.parentPath;
  while (memberPath.isMemberExpression()) {
    const code = content.slice(identifierPath.node.end, memberPath.node.end);
    const pluginName = pluginLookup[code];
    if (pluginName) {
      return pluginName;
    }

    memberPath = memberPath.parentPath;
  }

  return '';
}
650584
function getByIdQuery(modelInstance) {
    const modelClass = modelInstance.getClass();
    const { idAttribute, modelName } = modelClass;

    return {
        table: modelName,
        clauses: [
            {
                type: FILTER,
                payload: {
                    [idAttribute]: modelInstance.getId(),
                },
            },
        ],
    };
}
263695
function inferImportTypes(ast, deps, compiler) {
  const newTypes = [];
  const patch = compiler.mapNode({
    Import(importNode, _) {
      const module = importNode.params[1];
      if (!deps[module.value]) {
        return importNode;
      }

      return compiler.mapNode({
        Pair(pair, _) {
          return pair;
        },
        BinaryExpression(binary, transform) {
          // "as" keywords only
          if (binary.value !== "as") {
            return binary;
          }

          return Object.assign({}, binary, {
            params: [
              transform(binary.params[0]),
              binary.params[1]
            ]
          });
        },
        // Fix any identifiers here
        Identifier(identifier, _) {
          const depAST = deps[module.value].ast;
          const {
            functions,
            globals,
            types,
            userTypes,
          } = depAST.meta.AST_METADATA;

          const fun = functions[identifier.value];
          const glbl = globals[identifier.value];
          const externType = types[identifier.value];
          const userType = userTypes[identifier.value];

          if (fun != null) {
            // function arguments and params are _always_ the first two params
            const [args, result] = fun.params;

            // since arguments is a single Node it may represent a single argument,
            // zero arguments or a sequence of arguments (a , list). All this means
            // is that we need to walk the node instead of mapping the parameters
            const typesOfArguments = [];
            compiler.walkNode({
              Assignment(assignment, _) {
                // assignments in type definitions are default arguments
                typesOfArguments.push(
                  Object.assign(assignment, {
                    params: [
                      assignment.params[0].params[1],
                      assignment.params[1],
                    ],
                  })
                );
              },
              Pair(argumentPair, _) {
                // function arguments are an identifier : type pairs
                // for type declarations we only need the types
                typesOfArguments.push(argumentPair.params[1]);
              },
            })(args);

            const typeArgs = Object.assign({}, args, {
              params: typesOfArguments,
            });

            // This will be the new typedef node added to the AST and compiled
            // into the binary.
            const newType = Object.assign({}, identifier, {
              type: result.type,
              params: [typeArgs, result],
              value: `__auto_type_${identifier.value}`,
              Type: "Typedef",
            });
            newTypes.push(newType);

            // for an import to become valid at this point it only needs to be an
            // <identifier : identifier> pair :)
            const patched = Object.assign({}, identifier, {
              value: ":",
              params: [
                identifier,
                Object.assign({}, identifier, { value: newType.value }),
              ],
              Type: "Pair",
            });

            return patched;
          }

          if (glbl != null) {
            // just set to the global type pair and peace out
            return Object.assign({}, identifier, {
              value: ":",
              params: [
                identifier,
                Object.assign({}, identifier, {
                  value: glbl.type,
                  type: glbl.type,
                  Type: "DeclType",
                }),
              ],
              Type: "Pair",
            });
          }

          // Unlike function types, user defined types are only needed for the
          // compiler to produce a valid binary.
          if (externType != null) {
            invariant(
              externType.meta.EXPORTED,
              "Imported type " +
                `"${externType.value}"` +
                " exists, but is not explicitly exported from " +
                module.value
            );
            newTypes.push(Object.assign({}, externType));
          }

          if (userType != null) {
            invariant(
              userType.meta.EXPORTED,
              "Imported type " +
                `"${userType.value}"` +
                " exists, but is not explicitly exported from " +
                module.value
            );
            newTypes.push(Object.assign({}, userType));
          }

          return null;
        },
      })(importNode);
    },
  })(ast);

  // types can be defined anywhere in a program, even as the very last bit
  return Object.assign({}, patch, { params: newTypes.concat(patch.params) });
}
343417
function(value, inferredType) {
      if (inferredType === 'boolean') {
        return value ? '' : undefined;
      } else if (inferredType !== 'object' && inferredType !== 'function'
          && value !== undefined) {
        return value;
      }
    }
736026
function getData (moduleName, require) {
    // get module - throws error if not defined
    var module = getModule(moduleName)
    // if require flag is set throw error if data is not defined
    if (require === true && !defined(module.meta.data)) {
        throw new Error(`no data for ${moduleName}`)
    }
    // return data if any
    return module.meta.data
}
791620
function getDepsFromDataObject(data, lookup) {
  var results = {};
  if (categories.length == 0) {
    for(var k in data.dependencies) {
      var dep = extractDep(data.dependencies[k]);
      results[k]=dep;
    }
  }

  if (lookup) {
    for (var i = 0; i < categories.length; i++) {
      var category = categories[i];
      for(var k in data[category]) {
        var spec = k + "@" + data[category][k];

        var specMatch = lookupSpecMatch(lookup, spec);

        // If there is no match in the lookup then this dependency was "deduped"
        if (specMatch) {
          results[k]=specMatch;
        }
      }
    }
  }
  return results;
}
1122028
function inferTypeByKeyword (schema) {
  for (const keyword of objectKeywords) {
    if (keyword in schema) return 'object'
  }
  for (const keyword of arrayKeywords) {
    if (keyword in schema) return 'array'
  }
  for (const keyword of stringKeywords) {
    if (keyword in schema) return 'string'
  }
  for (const keyword of numberKeywords) {
    if (keyword in schema) return 'number'
  }
  return schema.type
}
431229
function iif(condition, trueResult, falseResult) {
    if (trueResult === void 0) {
        trueResult = _empty__WEBPACK_IMPORTED_MODULE_1__["EMPTY"];
    }
    if (falseResult === void 0) {
        falseResult = _empty__WEBPACK_IMPORTED_MODULE_1__["EMPTY"];
    }
    return Object(_defer__WEBPACK_IMPORTED_MODULE_0__["defer"])(function () { return condition() ? trueResult : falseResult; });
}
539741
function isProbablyWebpackModule (node) {
        return isElementOfArray(node) &&
          isArgumentToFunctionCall(node.parent()) &&
          isIIFECall(node.parent().parent())
      }
1112544
function reportInferrableType(node, typeNode, initNode) {
            if (!typeNode || !initNode || !typeNode.typeAnnotation) {
                return;
            }

            if (!isInferrable(typeNode, initNode)) {
                return;
            }

            const typeMap = {
                TSBooleanKeyword: "boolean",
                TSNumberKeyword: "number",
                TSStringKeyword: "string",
            };

            const type = typeMap[typeNode.typeAnnotation.type];

            context.report({
                node,
                message:
                    "Type {{type}} trivially inferred from a {{type}} literal, remove type annotation.",
                data: {
                    type,
                },
                fix: fixer => fixer.remove(typeNode),
            });
        }
1124423
def infer_returned_object(pyfunction, args):
    """"""
    object_info = pyfunction.pycore.object_info
    result = object_info.get_exact_returned(pyfunction, args)
    if result is not None:
        return result
    result = _infer_returned(pyfunction, args)
    if result is not None:
        if args and pyfunction.get_module().get_resource() is not None:
            params = args.get_arguments(
                pyfunction.get_param_names(special_args=False))
            object_info.function_called(pyfunction, params, result)
        return result
    result = object_info.get_returned(pyfunction, args)
    if result is not None:
        return result
    hint_return = get_type_hinting_factory(pyfunction.pycore.project).make_return_provider()
    type_ = hint_return(pyfunction)
    if type_ is not None:
        return rope.base.pyobjects.PyObject(type_)