This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const plugin = babel => { | |
const {types: t} = babel | |
return { | |
inherits: inheritsOpts, | |
name: 's2s-jsdoc-creator', | |
visitor: { | |
Function(nodePath, state) { | |
const comment = `* | |
* @hoge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const {transform} = require('babel-core') | |
const src = 'function hoge() {}' | |
const plugin = () => { | |
const visitor = { | |
Function: (nodePath) => { | |
nodePath.addComment('leading', 'hoge') | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Fraction { | |
constructor(num, denom) { | |
this.num = num | |
this.denom = denom | |
this._reduce() | |
} | |
_reduce() { | |
if (this.num === 0) { | |
this.denom = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const generateObject = (scope, ...nodes) => { | |
return t.objectExpression( | |
nodes.map(node => { | |
return t.objectProperty(scope.generateUidIdentifier(), node) | |
}) | |
) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const {transform} = require('babel-core') | |
const src = ` | |
const a = 1 | |
const b = 2 | |
let c, d, e | |
c = 1 * 2 + 3 + 4 * 2 | |
console.log(c) | |
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const {transform} = require('babel-core') | |
const babylon = require('babylon') | |
const WasCreated = Symbol('WasCreated') | |
const source = ` | |
let b = 0 | |
console.log(b) | |
b = b + 2 | |
console.log(b) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const {transform} = require('babel-core') | |
const WasCreated = Symbol('WasCreated') | |
const src = ` | |
class Integer { | |
value: number | |
constructor(value: number) { | |
this.value = Math.floor(value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const babylon = require('babylon') | |
const parse = (source) => { | |
try { | |
const ast = babylon.parse(source) | |
delete ast.tokens | |
return {ast} | |
} catch (err) { | |
return {error: err} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Dog { | |
voice() { | |
return 'wanwan' | |
} | |
} | |
class Cat { | |
voice() { | |
return 'nya-n' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env node | |
const path = require('path') | |
const express = require('express') | |
const browserify = require('browserify') | |
const app = express() | |
const sourcePath = path.resolve(process.argv.length <= 2 ? './' : process.argv[2]) | |
app.use((req, res, next) => { |