angular.module('sdk.directives.ccZippy') | |
.directive('ccZippy', function() { | |
var defaultIfUndefined = function(scope, property, defaultVal){ | |
return scope[property] = scope[property] === undefined ? defaultVal : scope[property]; | |
}; | |
return { | |
restrict: 'E', | |
replace: true, |
import Promise from 'bluebird' | |
import MongoDB from 'mongodb' | |
Promise.promisifyAll(MongoDB) | |
async function findEveryone(db) { | |
const people = db.collection('people') | |
const everyone = await people.find().toArrayAsync() | |
return everyone.map( x => x.name ) | |
} |
Note: I'm not involved in Prepack in any way — please correct me if I say anything incorrect below!
A few people have asked me if Prepack and Svelte are similar projects with similar goals. The answer is 'no, they're not', but let's take a moment to explore why.
Prepack describes itself as a 'partial evaluator for JavaScript'. What that means is that it will run your code in a specialised interpreter that, rather than having some effect on the world (like printing a message to the console), will track the effects that would have happened and express them more directly.
So for example if you give it this code...
function countCSSRules() { | |
var results = '', | |
log = ''; | |
if (!document.styleSheets) { | |
return; | |
} | |
for (var i = 0; i < document.styleSheets.length; i++) { | |
countSheet(document.styleSheets[i]); | |
} | |
function countSheet(sheet) { |
Resources that go beyond the official documentation. To learn Svelte or to find things to use in your own projects. If you have nice resources to add, please comment below.
- Main tutorial https://svelte.dev/tutorial/basics
- API https://svelte.dev/docs
- Main repo: https://github.com/sveltejs/svelte
// Async/Await requirements: Latest Chrome/FF browser or Babel: https://babeljs.io/docs/plugins/transform-async-to-generator/ | |
// Fetch requirements: Latest Chrome/FF browser or Github fetch polyfill: https://github.com/github/fetch | |
// async function | |
async function fetchAsync () { | |
// await response of fetch call | |
let response = await fetch('https://api.github.com'); | |
// only proceed once promise is resolved | |
let data = await response.json(); | |
// only proceed once second promise is resolved |
// Create our server | |
var server; | |
server = http.createServer(function(req,res){ | |
// Set CORS headers | |
res.setHeader('Access-Control-Allow-Origin', '*'); | |
res.setHeader('Access-Control-Request-Method', '*'); | |
res.setHeader('Access-Control-Allow-Methods', 'OPTIONS, GET'); | |
res.setHeader('Access-Control-Allow-Headers', '*'); | |
if ( req.method === 'OPTIONS' ) { | |
res.writeHead(200); |
Attention: the list was moved to
https://github.com/dypsilon/frontend-dev-bookmarks
This page is not maintained anymore, please update your bookmarks.