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
// api/controllers/SomeController.js | |
module.exports = { | |
/** | |
* @param req | |
* @param res | |
*/ | |
create: (req, res) => { | |
let love = sails.services.SomeService.getLove() |
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
// main.js is your Webpack entry point. "bootstrap.desktop" and "bootstrap.mobile" load dependencies based on the browser width | |
/** | |
* @see {@link https://stackoverflow.com/questions/1038727/how-to-get-browser-width-using-javascript-code#1038781} | |
*/ | |
const browserWidth = Math.max( | |
document.body.scrollWidth, | |
document.documentElement.scrollWidth, | |
document.body.offsetWidth, | |
document.documentElement.offsetWidth, |
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
import Vue from 'vue' | |
import 'babel-polyfill' | |
import Component from '~/components/Component' | |
import { | |
mount | |
} from 'vue-test-utils' | |
import sinon from 'sinon' | |
import { | |
assert | |
} from 'chai' |
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 a = () => { | |
return new Promise(resolve => { | |
console.log('a') | |
resolve(1) | |
}) | |
} | |
const b = () => { | |
return new Promise(resolve => { | |
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
/** | |
* @see {@url https://stackoverflow.com/questions/30452263/is-there-a-mechanism-to-loop-x-times-in-es6-ecmascript-6-without-mutable-varia#answer-30452949} | |
*/ | |
const times = x => f => { | |
if (x > 0) { | |
f() | |
times (x - 1) (f) | |
} | |
} |
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
<template> | |
<div> | |
<!-- User form --> | |
</div> | |
</template> | |
<script> | |
import User from 'src/decorators/UserDecorator' | |
export default { |
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
/** | |
* This way, you can import the functional program function and use in two ways. You don't have to fear any name collisions. | |
*/ | |
let element = [{key: 1, value: a}, {key: 2, value: b}] | |
// Functional program usage | |
flow([ | |
map(element => omit(['key'])) | |
])(elements) |
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
<template> | |
<div> | |
<p>I got {{ amount }} {{ 'cookie' | pluralize(amount) }}</p> | |
<button @click="decrement">Decrement</button> | |
</div> | |
</template> | |
<script> | |
export default { | |
data: () => ({ |
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
import moment from 'moment' | |
import flow from 'lodash/flow' | |
import map from 'lodash/fp/map' | |
/** | |
* Returns days relative to first one, e. g.: 0, 2, 9, 10, 11 | |
* | |
* @params {array} dates | |
* @returns {array} | |
*/ |
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
// It might be that you need components loaded dynamically. You can use the following function | |
const getComponentName = (identifier, method = 'post') => { | |
return `${identifier.replace(/([A-Z])/g, '-$1').toLowerCase().replace(/^-(.*)$/, '$1')}-${method}` | |
} | |
// Example: getComponentName('PriceTable', 'get') yields 'price-table-get' |
OlderNewer