from https://github.com/npm-dom/is-dom/blob/master/index.js
554191
function isNode(val) {
  if (!isObject(val)) {
    return false;
  }
  if (isDefined(window) && isObject(window.Node)) {
    return val instanceof window.Node;
  }
  return typeof val.nodeType === 'number' && typeof val.nodeName === 'string';
}
248722
public function index()
    {
        if (!userHasPermission('admin:cdn:manager:object:browse')) {
            unauthorised();
        }

        $oInput                    = Factory::service('Input');
        $this->data['sBucketSlug'] = $oInput->get('bucket');

        $oAsset = Factory::service('Asset');
        $oAsset->library('KNOCKOUT');
        //  @todo (Pablo - 2018-12-01) - Update/Remove/Use minified once JS is refactored to be a module
        $oAsset->load('admin.mediamanager.js', 'nails/module-cdn');

        $sBucketSlug      = $oInput->get('bucket');
        $sCallbackHandler = $oInput->get('CKEditor') ? 'ckeditor' : 'picker';

        if ($sCallbackHandler === 'ckeditor') {
            $aCallback = [$oInput->get('CKEditorFuncNum')];
        } else {
            $aCallback = array_filter((array) $oInput->get('callback'));
        }

        $oAsset->inline(
            'ko.applyBindings(
                new MediaManager(
                    "' . $sBucketSlug . '",
                    "' . $sCallbackHandler . '",
                    ' . json_encode($aCallback) . ',
                    ' . json_encode((bool) $oInput->get('isModal')) . '
                )
            );',
            'JS'
        );

        Helper::loadView('index');
    }
784414
function getGlob() {
			if (isNode) {
				return loader.import("@node-require", { name: module.id })
					.then(function(nodeRequire) {
						return nodeRequire("glob");
					});
			}

			return Promise.resolve();
		}
240911
async function component({repoDir=process.cwd(), outDir=process.cwd()}={}) {
  repoDir = path.isAbsolute(repoDir) ? repoDir : path.resolve(process.cwd(), repoDir);

  outDir = path.isAbsolute(outDir) ? outDir : path.resolve(process.cwd(), outDir);

  const dest = path.resolve(outDir, 'stats.json');

  const promisedData = files.map(filename => {
    console.log(`Reading file: ${repoDir}/${filename}`);
    return loadJsonFile(path.resolve(repoDir, filename));
  });

  promisedData.push(gitTags(repoDir));

  const [package, bower, origami, tags] = await Promise.all(promisedData);

  const statsData = {
    module_name: bower.name,
    keywords: package.keywords,
    repo_home_url: package.homepage,
    is_stable: true,
    tag_name: tags[tags.length-1].tag_name,
    datetime_created: tags[tags.length-1].datetime_created,
    versions: tags,
    has_css: bower.main.indexOf('main.scss') !== -1,
    has_js: bower.main.indexOf('main.js') !== -1,
    dependencies: bower.dependencies,
    description: package.description,
    origami_type: origami.origamiType,
    origami_category: origami.origamiCategory,
    origami_version: origami.origamiVersion,
    support: package.bugs.url,
    support_status: origami.supportStatus,
    brower_features: origami.browserFeatures,
    demos: origami.demos
  };
  console.log(`Generating ${chalk.cyan(dest)}`);
  await writeJsonFile(dest, statsData);
  return statsData;
}
230178
function(code) {
    var modules = [];

    var lex = Espruino.Core.Utils.getLexer(code);
    var tok = lex.next();
    var state = 0;
    while (tok!==undefined) {
      if (state==0 && tok.str=="require") {
        state=1;
      } else if (state==1 && tok.str=="(") {
        state=2;
      } else if (state==2 && (tok.type=="STRING")) {
        state=0;
        var module = tok.value;
        if (!isBuiltIn(module) && modules.indexOf(module)<0)
          modules.push(module);
      } else
        state = 0;
      tok = lex.next();
    }

    return modules;
  }
80772
function readModels (dir, relative) {
  const fs = require('fs')
  const path = require('path')
  // eslint-disable-next-line no-eval
  const evalRequire = eval('require')
  const list = []
  function readRecursively (dir, root, list) {
    fs.readdirSync(dir).forEach(file => {
      const filePath = path.join(dir, file)
      if (fs.statSync(filePath).isDirectory()) {
        // walk through
        readRecursively(filePath, root, list)
      } else {
        // only '*.js' file will be added as model
        if (file.match(/^(\.\/)?([\w]+\/)*([\w]+\.js)$/)) {
          // bundler like webpack will complain about using dynamic require
          // See https://github.com/webpack/webpack/issues/196
          // use `eval` trick to avoid this
          let model = evalRequire(filePath)
          // handling es6 module
          if (model.__esModule) {
            model = model.default
          }
          // get relative path of the root path
          const pathNS = path.join(path.relative(root, dir), file)
          list.push(checkNS(model) ? model : {namespace: getNamespace(pathNS, relative), ...model})
        }
      }
    })
  }
  const p = path.resolve(__dirname, dir)
  readRecursively(p, p, list)
  return list
}
94268
function createMiddleware(options) {
  /**
   * Express middleware handling Git API Blob requests
   *
   * Only a small subset will be implemented
   *
   * @param {Request} req Request object
   * @param {Response} res Response object
   * @param {callback} next next middleware in chain
   *
   * @see https://developer.github.com/v3/git/blobs/#get-a-blob
   */
  return (req, res, next) => {
    // GET /repos/:owner/:repo/git/blobs/:file_sha
    const { owner } = req.params;
    const repoName = req.params.repo;
    const sha = req.params.file_sha;
    const host = req.mappedSubDomain ? `localhost:${options.listen[req.protocol].port}` : req.headers.host;

    const repPath = resolveRepositoryPath(options, owner, repoName);

    if (sha.match(/[0-9a-f]/g).length !== 40) {
      // invalid sha format
      res.status(422).json({
        message: 'The sha parameter must be exactly 40 characters and contain only [0-9a-f].',
        documentation_url: 'https://developer.github.com/v3/git/blobs/#get-a-blob',
      });
      return;
    }
    getObject(repPath, sha)
      .then(({ object: content }) => {
        res.json({
          sha,
          size: content.length,
          url: `${req.protocol}://${host}${req.path}`,
          content: `${content.toString('base64')}\n`,
          encoding: 'base64',
        });
      })
      .catch((err) => {
        // TODO: use generic errors
        if (err.code === 'ReadObjectFail') {
          options.logger.debug(`[blobHandler] resource not found: ${err.message}`);
          res.status(404).json({
            message: 'Not Found',
            documentation_url: 'https://developer.github.com/v3/git/blobs/#get-a-blob',
          });
        } else {
          options.logger.debug(`[blobHandler] code: ${err.code} message: ${err.message} stack: ${err.stack}`);
          next(err);
        }
      });
  };
}
1315807
function(elm) {
			var index = -1;
			var parts = [];
			function hasid(elm) {
				if (elm.id) {
					try {
						gui.DOMPlugin.q(elm.parentNode, elm.id);
						return true;
					} catch (malformedexception) {}
				}
				return false;
			}
			while (elm && elm.nodeType === Node.ELEMENT_NODE) {
				if (hasid(elm)) {
					parts.push("#" + elm.id);
					elm = null;
				} else {
					if (elm.localName === "body") {
						parts.push("body");
						elm = null;
					} else {
						index = gui.DOMPlugin.ordinal(elm) + 1;
						parts.push(">" + elm.localName + ":nth-child(" + index + ")");
						elm = elm.parentNode;
					}
				}
			}
			return parts.reverse().join("");
		}
803199
function walkTree(dirPath) {
    let filesindir = [];
    return new Promise((res, rej) => {
        if (dirPath.match(/node_modules|.git|bower|LICENCE|tree.json/)) {
            rej([]);
        }

        const relative = `${dirPath}/`,
            readPath = dirPath === '.' ? ROOT + '/' : dirPath + '/';

        readdir(path.resolve(readPath))
            .then(files => {
                files.map(async(i) => {
                    let file;
                    if (fs.statSync(path.join(relative, i)).isDirectory()) {
                        file = {
                            name: i,
                            type: 'dir',
                            path: `${relative}${i}`,
                            files: {}
                        }
                    } else {
                        file = {
                            id: id,
                            name: i,
                            type: 'file',
                            path: `${relative}${i}`,
                            imports: [],
                            exports: []
                        }
                        AllFiles[id++] = file;
                    }
                    filesindir.push(file);
                })
                res(filesindir);
            })
            .catch(err => {
                console.error(err);
                rej([]);
            })
    })
}
1263963
function (tplContent, name, isModule) {
            var root = compiler.parse(tplContent, name);
            uuid = 0;
            xtplAstToJs.isModule = isModule;
            return genTopFunction(xtplAstToJs, root.statements);
        }
196685
function() {
    var packageName;
    var parentFolderName = path.basename(path.resolve('..'));
    var isSubPackage = parentFolderName === 'node_modules';
    var isLocalDepsAvailable = fs.existsSync('node_modules/grunt-autoprefixer') && fs.existsSync('node_modules/grunt-contrib-cssmin');

    if (isSubPackage && !isLocalDepsAvailable) {
        packageName = 'load-grunt-parent-tasks';
    } else {
        packageName = 'load-grunt-tasks';
    }

    return packageName;
}
214055
function(context, pkg, isRoot, deps){
		var stealPkg = utils.filter(deps, function(dep){
			return dep && dep.name === "steal";
		})[0];

		if(stealPkg) {
			return crawl.fetchDep(context, pkg, stealPkg, isRoot)
				.then(function(childPkg){
					if(childPkg) {
						return crawl.deps(context, childPkg);
					}
				});
		} else {
			return Promise.resolve();
		}
	}
546048
function() {
      'use strict';
      var filesToCopy = {
         'control.json': 'control.json',
         'gitignore': '.gitignore',
         'default.theme/css/control.css': 'default.theme/css/' + this.placeholder.name + '.css'
      };
      var integrationTechnology = this.placeholder.laxarIntegrationTechnology;

      if( this.placeholder.infrastructure ) {
         filesToCopy[ 'README.md' ] = 'README.md';
         if( integrationTechnology === 'react' ) {
            filesToCopy[ 'bower.react.json' ] = 'bower.json';
         }
         else {
            filesToCopy[ 'bower.json' ] = 'bower.json';
         }
      }


      if( integrationTechnology === 'plain' ) {
         filesToCopy[ 'control.plain.js' ] = this.placeholder.name + '.js';
      }
      else if( integrationTechnology === 'angular' ) {
         filesToCopy[ 'control.angular.js' ] = this.placeholder.name + '.js';
      }
      else if( integrationTechnology === 'react' ) {
         filesToCopy[ 'control.react.jsx' ] = this.placeholder.name + '.jsx';
      }

      for( var file in filesToCopy ) {
         if( filesToCopy.hasOwnProperty( file ) ) {
            this.fs.copyTpl(
               this.templatePath( file ),
               this.destinationPath(
                  path.join( this.controlDirname, this.placeholder.name, filesToCopy[ file ] )
               ),
               this.placeholder
            );
         }
      }
   }
329022
function isSchema(blob) {
    // A schema will have one of these
    return blob.properties !== undefined || blob.enum !== undefined || blob.items
        !== undefined || blob.type !== undefined;
}
632289
function status() {
  var tasks = [],
      cwd = process.cwd();

  findRepos(function(err, repos) {
    if (err) return console.log(err);
    repos.forEach(function(repo) {
      tasks.push(function(done) {
        repo.status(function(err, status) {
          if (err) return done(err);
          if (argv.b) {
            repo.branch(function(err, head) {
              if (err) return done(err);
              done(null, {status: status, head: head});
            });
          }
          else {
            done(null, {status: status});
          }
        });
      });
    });
    async.series(tasks, function(err, results) {
      if (err) return console.log(err);

      var row,
          col,
          res,
          file,
          head = [],
          table,
          symbol;

      head.push('Repo');
      if (argv.b) {
        head.push('Branch');
      }
      head.push('Status');

      table = new Table({
        head: head,
        style: {
          compact: true,
          'padding-left': 1,
          'padding-right': 1,
          head: ['white', 'bold']
        }
      });

      results.forEach(function(res) {
        var row = [];

        row.push(res.status.repo.path.replace(cwd + '/', ''));
        if (argv.b) {
          row.push(res.head.name);
        }
        row.push(res.status.clean ? 'Clean'.green : 'Changed'.red);
        table.push(row);

        if (argv.v) {
          for (var name in res.status.files) {
            row = [];
            row.push('');
            if (argv.b) {
              row.push('');
            }
            switch (res.status.files[name].type) {
              case 'A':
                symbol = '+'.green; break;
              case 'D':
                symbol = '-'.red; break;
              case 'M':
                symbol = '*'.yellow; break;
              default:
                symbol = '~'.grey; break;
            }
            row.push(' ' + symbol + ' ' + name);
            table.push(row);
          }
        }
      });

      console.log(table.toString());
    });
  });
}
1061343
function canonical() {
  var tags = document.getElementsByTagName('link');
  // eslint-disable-next-line no-cond-assign
  for (var i = 0, tag; tag = tags[i]; i++) {
    if (tag.getAttribute('rel') === 'canonical') {
      return tag.getAttribute('href');
    }
  }
}
266963
function(){
		var prodHtmlPath = this.html = this.findHTML();

		if(!prodHtmlPath) {
			return;
		}

		return readFile(prodHtmlPath, "utf8")
		.then(function(src){
			this.originalSource = src;

			var $ = cheerio.load(src);
			var stealScript;
			$("script").each(function(idx, el){
				var $el = $(el);
				var src = $el.attr("src");
				if(/steal\.production\.js/.test(src)) {
					stealScript = $el;
					return false;
				}
			});

			if(stealScript) {
				stealScript.attr("env", "electron-production");
				return writeFile(prodHtmlPath, $.html(), "utf8");
			}
		}.bind(this))
		.catch(function(){
			// We don't want the copy to fail just because of this
		});

	}