How to use the builtin-modules.join function in builtin-modules

To help you get started, we’ve selected a few builtin-modules examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sumanjs / suman / lib / convert-files / convert-dir2.js View on Github external
const stream = require('stream');
const cp = require('child_process');

//npm
const async = require('async');
const builtinModules = require('builtin-modules');
const chmodr = require('chmodr');

//project
const _suman = global.__suman = (global.__suman || {});
const su = require('suman-utils');
const nfsa = require('./nfsa');

//////////////////////////////////////////////////////////

const coreModuleMatches = new RegExp(`("|')(${ builtinModules.join('|') })\\1`);

const preserveFunctionNames = true;

const regexes = {

  matchesStdFnWith0Args: /function\s*(\S*)\(\s*\)\s*\{/,        // function foo ( ) {
  matchesStdFnWith1Arg: /function\s*(\S*)\s*\(\s*(\S+)\s*\)\s*\{/, ///function\s*\(\s*\S+\s*\)\s*\{/,      // function foo ( ) {
  matchesStdFnWithAnyNumberOfArgs: /function\s*(\S*)\s*\(.*\)\s*\{/, ///function\s*\(\s*\S+\s*\)\s*\{/,      // function foo ( ) {
  matchesArrowFnWith0Args: /\(\s*\)\s*=>\s*\{/,
  matchesArrowFnWith1Arg: /\(\s*\(?\s*(\S+)\s*\)?\s*=>\s*\{/,   // () are optional for one arg
  matchesDescribe: /^\s*describe\s*\(/,
  matchesContext: /^\s*context\s*\(/,
  matchesDescribeSkip: /^\s*describe.skip\s*\(/,
  matchesContextSkip: /^\s*context.skip\s*\(/,
  matchesIt: /^\s*it\s*\(/,
  matchesItSkip: /^\s*it.skip\s*\(/,
github sumanjs / suman / lib / convert-files / convert-dir.js View on Github external
const fs = require('fs');
const path = require('path');
const stream = require('stream');

//npm
const builtinModules = require('builtin-modules');
const chmodr = require('chmodr');

//project
const _suman = global.__suman = (global.__suman || {});
const su = require('suman-utils');
const nfsa = require('./nfsa');

//////////////////////////////////////////////////////////

const coreModuleMatches = new RegExp(`("|')(${ builtinModules.join('|') })\\1`);

const preserveFunctionNames = true;

const regexes = {

  matchesStdFnWith0Args: /function\s*(\S*)\(\s*\)\s*\{/,        // function foo ( ) {
  matchesStdFnWith1Arg: /function\s*(\S*)\s*\(\s*(\S+)\s*\)\s*\{/, ///function\s*\(\s*\S+\s*\)\s*\{/,      // function foo ( ) {
  matchesStdFnWithAnyNumberOfArgs: /function\s*(\S*)\s*\(.*\)\s*\{/, ///function\s*\(\s*\S+\s*\)\s*\{/,      // function foo ( ) {
  matchesArrowFnWith0Args: /\(\s*\)\s*=>\s*\{/,
  matchesArrowFnWith1Arg: /\(\s*\(?\s*(\S+)\s*\)?\s*=>\s*\{/,   // () are optional for one arg
  matchesDescribe: /^\s*describe\s*\(/,
  matchesContext: /^\s*context\s*\(/,
  matchesDescribeSkip: /^\s*describe.skip\s*\(/,
  matchesContextSkip: /^\s*context.skip\s*\(/,
  matchesIt: /^\s*it\s*\(/,
  matchesItSkip: /^\s*it.skip\s*\(/,
github sumanjs / suman / lib / convert-files / convert.js View on Github external
const lines = String(file).split('\n');  //replace all lines but new line chars

console.log(lines);

const result = [];

//const coreModuleMatches = /'^(var|const|,)[a-z\$\_]{1,}=require\((\'|")(assert|fs|path)(\'|")\)[;|,]{0,1}$/;

//const coreModuleMatches = '^\s*(?:var|const|,)\s*([a-z$_]+\s*=\s*require\((\'|")(?:(' + builtinModules.join('|') + '))\2\),?[\n\r\t\s]*)*;$';

//const coreModuleMatches = `^\s*(var|const|,)\s*[a-zA-Z\_\$]+\s*=\s*require\(('|")(${builtinModules.join('|')})('|")\)`;

//const coreModuleMatches = new RegExp(`require\(('|")(${builtinModules.join('|')})('|")\)`);

const coreModuleMatches  = new RegExp(`("|')(${ builtinModules.join('|') })\\1`);
//let rgxStr = 'require\(("|\')' + builtinModules.join('|') + '("|\')\)\\1';

console.log('rgxStr:', coreModuleMatches);

//let coreModuleMatches = new RegExp(rgxStr);

const coreModules = [];

let firstDescribeMatch = false;

const indexes = {
    'index_of_top_level_describe': null
};

lines.forEach(function (line, index) {

builtin-modules

A static list of the Node.js builtin modules from the latest Node.js version

MIT
Latest version published 5 months ago

Package Health Score

76 / 100
Full package analysis