Create the element file.

@returns {NodeJS.ReadWriteStream}
503380
function createElementScript() {
  return gulp
    .src(`./${config.src.path}/${config.src.entrypoint}`)
    .pipe(
      modifyFile(content => {
        /**
         * Strip the imports and exports out of the parse code and return them.
         *
         * @param {Program} parsedCode
         *   The parsed code.
         * @returns {{imports:Map<number,Object>, exports:Map<number,Object>}}
         */
        const stripImportsAndExports = parsedCode => {
          // Get info about the code.
          const codeIndexesToRemove = [];
          const imports = new Map();
          const exports = new Map();
          for (const [nodeIndex, node] of parsedCode.body.entries()) {
            switch (node.type) {
              case 'ImportDeclaration':
                for (const specifiers of node.specifiers) {
                  let importedName;
                  if (specifiers.type === 'ImportDefaultSpecifier') {
                    importedName = specifiers.local.name;
                  } else if (specifiers.type === 'ImportSpecifier') {
                    importedName = specifiers.imported.name;
                  }

                  if (
                    importedName != null &&
                    importedName.toLowerCase().startsWith('catalyst')
                  ) {
                    imports.set(nodeIndex, node);
                    codeIndexesToRemove.push(nodeIndex);
                  } else {
                    throw new Error(
                      `Cannot automatically process import "${importedName}."`
                    );
                  }
                }
                break;

              case 'ExportDefaultDeclaration':
              case 'ExportNamedDeclaration':
                exports.set(nodeIndex, parsedCode.body[nodeIndex]);
                codeIndexesToRemove.push(nodeIndex);
                break;

              // Different type? Do nothing.
              default:
            }
          }

          // Remove imports and exports.
          parsedCode.body = parsedCode.body.filter(
            (e, i) => !codeIndexesToRemove.includes(i)
          );

          return {
            imports: imports,
            exports: exports
          };
        };

        /**
         * Replace catalyst element's imports with globally accessible object import.
         *
         * @param {Program} parsedCode
         *   The parsed code with the imports already stripped out.
         * @param {Map<number,Object>} imports
         *   The imports that have been stripped out of the parsed code.
         */
        const processImports = (parsedCode, imports) => {
          for (const [importDefIndex, importDef] of imports) {
            for (const specifier of Object.values(importDef.specifiers)) {
              const localName = specifier.local.name;
              const importedName = specifier.imported
                ? specifier.imported.name
                : localName;

              if (importedName.toLowerCase().startsWith('catalyst')) {
                parsedCode.body.splice(
                  importDefIndex,
                  0,
                  esprima.parseScript(
                    `let ${localName} = window.CatalystElements.${importedName};`
                  )
                );
              } else {
                throw new Error(
                  `Cannot automatically process import "${importedName}."`
                );
              }
            }
          }
        };

        /**
         * Replace exports with globally accessible object exports.
         *
         * @param {Program} parsedCode
         *   The parsed code with the exports already stripped out.
         * @param {Map<number,Object>} exports
         *   The exports that have been stripped out of the parsed code.
         */
        const processExports = (parsedCode, exports) => {
          const exportNamesUsed = [];

          // Replace exports with globally accessible object exports.
          for (const [exportDefIndex, exportDef] of exports) {
            if (exportDef.declaration === null) {
              for (const specifier of Object.values(exportDef.specifiers)) {
                const localName = specifier.local.name;
                const exportedName = specifier.imported
                  ? specifier.imported.name
                  : localName;

                if (!exportNamesUsed.includes(exportedName)) {
                  parsedCode.body.splice(
                    exportDefIndex,
                    0,
                    esprima.parseScript(
                      `window.CatalystElements.${exportedName} = ${localName};`
                    )
                  );
                  exportNamesUsed.push(exportedName);
                }
              }
            } else if (exportDef.declaration.type === 'Identifier') {
              if (!exportNamesUsed.includes(exportDef.declaration.name)) {
                parsedCode.body.splice(
                  exportDefIndex,
                  0,
                  esprima.parseScript(
                    `window.CatalystElements.${exportDef.declaration.name} = ${
                      exportDef.declaration.name
                    };`
                  )
                );
                exportNamesUsed.push(exportDef.declaration.name);
              }
            } else {
              console.error(
                `Cannot automatically process declaration in ${exportDef.type}.`
              );
            }
          }
        };

        // Parse the code.
        const parsedCode = esprima.parseModule(content);

        // Run functions defined above.
        const { imports, exports } = stripImportsAndExports(parsedCode);
        processImports(parsedCode, imports);
        processExports(parsedCode, exports);

        // Generate the updated code.
        return (
          'window.CatalystElements = window.CatalystElements || {};\n' +
          `${escodegen.generate(parsedCode)}`
        );
      })
    )
    .pipe(
      rename(path => {
        path.basename = config.element.tag;
        path.extname = `.script${path.extname}`;
      })
    )
    .pipe(gulp.dest(`./${config.temp.path}`));
}
174137
function (node) {
        var element = this._createElement(node);
        this._setAttributesTo(element);
        this._appendChildrenTo(element);
        return node.appendChild(element);
    }
30276
function parseFile(file, done) {

    // create stream
    var saxStream = sax.createStream(options.strict, options);

    saxStream.on('error', function(e) {
      // unhandled errors will throw, since this is a proper node
      // event emitter.
      console.error('error!', e);
      // clear the error
      this._parser.error = null;
      this._parser.resume();

      // TODO: send to error callback
    });

    saxStream.on('opentag', function(node) {
      var name = node.name,
          value;

      if (parsedTags.indexOf(name) !== -1) {
        var parser = parsers[name];

        if (!parser) {
          throw new Error('[modelgen] no parser for tag <' + name + '>');
        }

        value = parser(node, this);
      }

      if (value) {
        stack.push(value);
      }
    });

    saxStream.on('closetag', function(nodeName) {
      if (parsedTags.indexOf(nodeName) !== -1) {
        stack.pop();
      }
    });

    saxStream.on('end', function() {

      var result = { byId: elementsById, byType: elementsByType };

      postProcess(result);
      done(null, result);
    });

    // pipe is supported, and it's readable/writable
    // same chunks coming in also go out.
    fs.createReadStream(file).pipe(saxStream);
  }
833807
private Element writeModule() {
        Element element = doc.createElement("module");
        rootElement.appendChild(element);
        return element;
    }
45318
function (file) {
                var _this = this;
                return new Promise(function (resolve, reject) {
                    return __awaiter(_this, void 0, void 0, function () {
                        var imageSrc, err_3, img;
                        var _this = this;
                        return __generator(this, function (_a) {
                            switch (_a.label) {
                                case 0:
                                    _a.trys.push([0, 2, , 3]);
                                    return [4 /*yield*/, readFile()];
                                case 1:
                                    imageSrc = _a.sent();
                                    return [3 /*break*/, 3];
                                case 2:
                                    err_3 = _a.sent();
                                    reject(err_3);
                                    return [3 /*break*/, 3];
                                case 3:
                                    img = new Image();
                                    img.onload = function () {
                                        return __awaiter(_this, void 0, void 0, function () {
                                            var ctx, width, _a;
                                            return __generator(this, function (_b) {
                                                switch (_b.label) {
                                                    case 0:
                                                        // set edited image canvas and dimensions
                                                        this.editedImage = ( /** @type {?} */(document.createElement('canvas')));
                                                        this.editedImage.width = img.width;
                                                        this.editedImage.height = img.height;
                                                        ctx = this.editedImage.getContext('2d');
                                                        ctx.drawImage(img, 0, 0);
                                                        // resize image if larger than max image size
                                                        width = img.width > img.height ? img.height : img.width;
                                                        if (!(width > this.options.maxImageDimensions.width))
                                                            return [3 /*break*/, 2];
                                                        _a = this;
                                                        return [4 /*yield*/, this.resize(this.editedImage)];
                                                    case 1:
                                                        _a.editedImage = _b.sent();
                                                        _b.label = 2;
                                                    case 2:
                                                        this.imageDimensions.width = this.editedImage.width;
                                                        this.imageDimensions.height = this.editedImage.height;
                                                        this.setPreviewPaneDimensions(this.editedImage);
                                                        resolve();
                                                        return [2 /*return*/];
                                                }
                                            });
                                        });
                                    };
                                    img.src = imageSrc;
                                    return [2 /*return*/];
                            }
                        });
                    });
                });
                /**
                 * read file from input field
                 * @return {?}
                 */
                function readFile() {
                    return new Promise(function (resolve, reject) {
                        /** @type {?} */
                        var reader = new FileReader();
                        reader.onload = function (event) {
                            resolve(reader.result);
                        };
                        reader.onerror = function (err) {
                            reject(err);
                        };
                        reader.readAsDataURL(file);
                    });
                }
            }
751172
async function writeFile(file, data) {
    return await fs.writeFile(file, stringify(data));
}
346020
public function create()
    {
        $file = $this->ensureEloquentFile($this->nodeRepository->make());
        $this->callBeforeListeners('create', [$file]);
        $this->callAfterListeners('create', [$file]);
        return $file;
    }
194683
void writeJsFile(TypeElement element, ElementVisitor visitor, String packagePath, String fn) {
		try (Writer w = fws.getFileObjectWriterInClassOutput(packagePath, fn)) {
			element.accept(visitor, w);
		} catch (IOException ioe) {
			messager.printMessage(Diagnostic.Kind.MANDATORY_WARNING, " FAILED TO CREATE : " + packagePath + "." + fn);
		}
	}
953557
function (file) {
    return new File({
      pattern: this.pattern,
      recurse: this.recurse,
      dirname: file.dirname,
      segment: file.segment,
      path: file.path
    });
  }
630537
protected OutputStream createOutputStream() throws IOException {
      if (asFile().isPresent()) {
         return new FileOutputStream(asFile().orElse(null));
      }
      return null;

   }
688540
function writeHTMLFile(options) {
  return new Promise(function(resolve, reject) {
    var templateFile = path.join(__dirname, '../template/cli.html');
     // read our template file
     fs.readFile(templateFile, 'utf8', function (err,data) {
      if (err) {
        reject(err);
      }
      // insert the generated json data
      var result = data.replace('{{ insertJSONHere }}', 'var embeddedJsonData = '+ options.json + ';');

      // write file to directory
      fs.writeFile(path.join(options.directory, 'index.html'), result, 'utf8', function (err) {
         if (err) {
          reject(err);
         }
         resolve(options.directory);
      });
    });
  });
}
521613
public static Stream<Element> stream(Element element) {
        return StreamSupport.stream(new ElementParentsIterable(element).spliterator(), false);
    }
962117
function createCssFile(target, cssContent) {
    var cssData = Buffer.from(cssContent);
    var writeFile$ = rxjs_1.bindNodeCallback(fs_1.writeFile);
    // Write css file to dist
    return writeFile$(target, cssData);
}
306581
public function _createElements() {

        $this->_generateId();

        $this->setElements([
            $this->createFormElement('text', 'filetypes', $this->getLabel(), [
                'id' => $this->getAttribute('id'),
            ]),

            $this->createFormElement('static', 'browser', null,
                '<span data-filetypesbrowser="'.$this->getAttribute('id').'"></span>'),

            $this->createFormElement('static', 'descriptions', null,
                '<div data-filetypesdescriptions="'.$this->getAttribute('id').'"></div>')
        ]);
    }
682483
function uploadDrive(p, callback) {

		var data = {};

		// Test for DOM element
		if (p.data &&
			(typeof (HTMLInputElement) !== 'undefined' && p.data instanceof HTMLInputElement)
		) {
			p.data = {file: p.data};
		}

		if (!p.data.name && Object(Object(p.data.file).files).length && p.method === 'post') {
			p.data.name = p.data.file.files[0].name;
		}

		if (p.method === 'post') {
			p.data = {
				title: p.data.name,
				parents: [{id: p.data.parent || 'root'}],
				file: p.data.file
			};
		}
		else {

			// Make a reference
			data = p.data;
			p.data = {};

			// Add the parts to change as required
			if (data.parent) {
				p.data.parents = [{id: p.data.parent || 'root'}];
			}

			if (data.file) {
				p.data.file = data.file;
			}

			if (data.name) {
				p.data.title = data.name;
			}
		}

		// Extract the file, if it exists from the data object
		// If the File is an INPUT element lets just concern ourselves with the NodeList
		var file;
		if ('file' in p.data) {
			file = p.data.file;
			delete p.data.file;

			if (typeof (file) === 'object' && 'files' in file) {
				// Assign the NodeList
				file = file.files;
			}

			if (!file || !file.length) {
				callback({
					error: {
						code: 'request_invalid',
						message: 'There were no files attached with this request to upload'
					}
				});
				return;
			}
		}

		// Set type p.data.mimeType = Object(file[0]).type || 'application/octet-stream';

		// Construct a multipart message
		var parts = new Multipart();
		parts.append(JSON.stringify(p.data), 'application/json');

		// Read the file into a  base64 string... yep a hassle, i know
		// FormData doesn't let us assign our own Multipart headers and HTTP Content-Type
		// Alas GoogleApi need these in a particular format
		if (file) {
			parts.append(file);
		}

		parts.onready(function(body, boundary) {

			p.headers['content-type'] = 'multipart/related; boundary="' + boundary + '"';
			p.data = body;

			callback('upload/drive/v2/files' + (data.id ? '/' + data.id : '') + '?uploadType=multipart');
		});

	}
704148
public boolean createNewFile() throws IOException
  {
    synchronized (LOCK) {
      if (! exists()) {
        clearStatusCache();
        WriteStreamOld s = openWrite();
        s.close();
        return true;
      }
    }

    return false;
  }
581019
function createElement(nodeName, ownerDocument, data){
    if (!ownerDocument) {
        ownerDocument = document;
    }
    if(supportsUnknownElements){
        return ownerDocument.createElement(nodeName);
    }
    if (!data) {
        data = getExpandoData(ownerDocument);
    }
    var node;

    if (data.cache[nodeName]) {
        node = data.cache[nodeName].cloneNode();
    } else if (saveClones.test(nodeName)) {
        node = (data.cache[nodeName] = data.createElem(nodeName)).cloneNode();
    } else {
        node = data.createElem(nodeName);
    }

    // Avoid adding some elements to fragments in IE < 9 because
    // * Attributes like `name` or `type` cannot be set/changed once an element
    //   is inserted into a document/fragment
    // * Link elements with `src` attributes that are inaccessible, as with
    //   a 403 response, will cause the tab/window to crash
    // * Script elements appended to fragments will execute when their `src`
    //   or `text` property is set
    return node.canHaveChildren && !reSkip.test(nodeName) && !node.tagUrn ? data.frag.appendChild(node) : node;
  }