// test-code.js
add :: (number, number) => number
function add (x, y) {
return x + y
}
This file contains hidden or 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
| { | |
| "version": "0.0.0", | |
| "scripts": { | |
| "to-comments": "babel --plugins=@andywer/babel-plugin-transform-dctypes-comments --no-babelrc test-code.js", | |
| "to-flow": "babel --plugins=@andywer/babel-plugin-transform-dctypes-to-flow --no-babelrc test-code.js", | |
| "to-flow-runtime": "NODE_ENV=development babel --plugins=@andywer/babel-plugin-transform-dctypes-to-flow,flow-runtime --no-babelrc test-code.js" | |
| }, | |
| "dependencies": { | |
| "@andywer/babel-cli-dctypes": "7.0.0-alpha.1", | |
| "@andywer/babel-plugin-transform-dctypes-comments": "^0.1.0", |
This file contains hidden or 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
| // src/plugins/dctypes.js | |
| import { types as tt } from "../tokenizer/types"; | |
| import { types as ct } from "../tokenizer/context"; | |
| import Parser from "../parser"; | |
| import "./flow"; | |
| const pp = Parser.prototype; | |
| export default function (instance) { |
This file contains hidden or 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 webpackMerge = require('webpack-merge') | |
| module.exports = { | |
| merge, | |
| addLoader, | |
| addPlugin | |
| } | |
| function merge (configSnippet) { | |
| return prevConfig => webpackMerge.smart(prevConfig, configSnippet) |
This file contains hidden or 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
| // With merge helper: | |
| module.exports = function exampleBlock () { | |
| return (context, { merge }) => merge({ | |
| module: { | |
| rules: [ | |
| { | |
| test: context.fileType('text/css'), | |
| use: ['sample-css-loader'] | |
| } |
This file contains hidden or 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 { group } = require('@webpack-blocks/core') | |
| module.exports = happypack | |
| function happypack (blocks) { | |
| return group(blocks.map(happyfyBlock)) | |
| } | |
| /** | |
| * Returns a new block wrapping `block` that creates a happypack loader config. |
This file contains hidden or 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 execa = require('execa') | |
| const Listr = require('listr') | |
| const rootListr = createListr([ | |
| { | |
| title: 'root', | |
| task: () => createListr([ | |
| { | |
| title: 'sleep 1s', | |
| task: () => execa.shell('echo "Sleeping 1s" && sleep 1 && echo "Done sleeping"') |
This file contains hidden or 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 execa = require('execa') | |
| const Listr = require('listr') | |
| const Observable = require('zen-observable') | |
| const rootListr = new Listr([ | |
| { | |
| title: 'root', | |
| task: () => new Listr([ | |
| { | |
| title: 'sleep 1s', |
What is this about?
- Make message passing using REST as easy and convenient as possible
- Convention over configuration for the basics, middleware concept for more powerful stuff
- Make it easy for people to design software in microservices and provide open APIs
Sample shows code of a small demo page for doing a simple mathematical addition of two numbers (method calculation). Calculation is done on the server.
This file contains hidden or 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
| import { createApi, Schema } from 'resticle' | |
| const api = createApi('/api') | |
| // Don't Repeat Yourself: Small middleware function to automatically provide `created_at` and `updated_at` timestamps | |
| api.use(function timestampsMiddleware (api) { | |
| api.extendModels((model, schema) => { | |
| // Extend schema if timestamps are not already defined | |
| schema.created_at = schema.created_at || Schema.Date() | |
| schema.updated_at = schema.updated_at || Schema.Date() |