View web-component.js
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
(function () { | |
expose('createMyComponent', register, factory); | |
/** | |
* Exposes your new component to the window or to a module | |
* | |
* @param {string} name - the factory name to expose | |
* @param {function} definition - the definition of your web component. registers to the document | |
* @param {function} factory - method for programmatically creating web component | |
*/ |
View web-component-class-example.js
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
'use strict'; | |
class NameCard extends HTMLElement { | |
set name(val) { | |
this._name = val; | |
this.render(); | |
} | |
get name() { | |
return this._name; |
View app.component.spec.ts
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
// src/app.components.ts | |
import {AppComponent} from './app.component'; | |
import {Injector} from '@angular/core'; | |
import {expect, it, describe, beforeEach, beforeEachProviders, inject} from '@angular/core/testing'; | |
describe('Component: AppComponent should be created', function () { | |
let fooComponent: FooComponent; | |
beforeEachProviders(() => [ |
View moment.pipe.ts
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 {Pipe, PipeTransform} from '@angular/core'; | |
import * as moment from 'moment'; | |
@Pipe({ | |
name: 'moment' | |
}) | |
export class MomentPipe implements PipeTransform { | |
transform(date, format) { | |
return moment(date).format(format); | |
} |
View angular-cli-build.js
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
/* global require, module */ | |
var Angular2App = require('angular-cli/lib/broccoli/angular2-app'); | |
const vendorNpmFiles = [ | |
'systemjs/dist/system-polyfills.js', | |
'systemjs/dist/system.src.js', | |
'zone.js/dist/**/*.+(js|js.map)', | |
'es6-shim/es6-shim.js', | |
'reflect-metadata/**/*.+(js|js.map)', |
View worker.js
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
function $worker() { | |
var workers = []; | |
// PUBLIC_API | |
return { | |
create: create, | |
runAll: runAll, | |
terminateAll: terminateAll, | |
list: list | |
} |
View inline-worker-example.js
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
function createWorker(fn) { | |
var blob = new Blob(['self.onmessage = ', fn.toString()], { type: 'text/javascript' }); | |
var url = URL.createObjectURL(blob); | |
return new Worker(url); | |
} |
View normal-web-worker.js
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
// New workers is created for a link to an external js file | |
var myWorker = new Worker('web-worker.js'); | |
// function to fire when a message is sent from the worker. | |
myWorker.onmessage = function (e) { | |
console.log(e.data); // HELLO WORLD | |
} | |
// send a message to the worker | |
myWorker.postMessage('hello world'); |
View inline-worker-in-action.js
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
var myWorker = createWorker(function (e) { | |
self.postMessage(e.data.toUpperCase()); | |
}); | |
myWorker.onMessage = function (e) { | |
console.log(e.data); // HELLO FROM AN INLINE WORKER! | |
} | |
myWorker.postMessage('hello from an inline worker!') |
View $worker-example.js
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
var myWorker = $worker().create(function () { | |
self.postMessage('Hello World'); | |
}); | |
myWorker.run().then(function (e) { | |
console.log(e.data); // 'Hello World' | |
}); |
OlderNewer