Skip to content

Instantly share code, notes, and snippets.

View shotamatsuda's full-sized avatar

Shota Matsuda shotamatsuda

  • Takram
  • Tokyo, Japan
View GitHub Profile
function Base() {
var privateVariable;
this._protectedVariable;
this.publicVariable;
function privateFunction() {}
}
Base.prototype._protectedFunction = function () {};
Base.prototype.publicFunction = function () {};
class Base {
constructor() {
const privateVariable
this._protectedVariable
this.publicVariable
function privateFunction() {}
}
_protectedFunction() {}
class Multiplier {
constructor(value) {
const coefficient = value
return {
by(other) {
return other * coefficient
},
}
}
export function Namespace(name) {
const symbol = Symbol(name)
return function namespace(object, init = () => ({})) {
if (object[symbol] === undefined) {
object[symbol] = init()
}
return object[symbol]
}
}
@shotamatsuda
shotamatsuda / Semaphore.js
Last active February 5, 2017 11:16
Promise based semaphore
import { Namespace } from '../core/Namespace'
export const internal = Namespace('Semaphore')
class Task {
constructor(semaphore, callback) {
const promises = [
new Promise((resolve, reject) => {
this.resolve = resolve
this.reject = reject
export function handleAction (action) {
const args = action.payload || []
switch (action.type) {
case DO_SOMETHING:
return doSomething(...args)
default:
break
}
}
@shotamatsuda
shotamatsuda / skia.sh
Created May 6, 2015 12:45
Build Skia as universal static libraries for OSX and iOS
readonly DEPOT_TOOLS_GIT='https://chromium.googlesource.com/chromium/tools/depot_tools.git'
readonly SKIA_GIT='https://skia.googlesource.com/skia.git'
readonly PROJECT_DIR="$(cd "$(dirname "$0")/../"; pwd)"
readonly BUILD_DIR="${PROJECT_DIR}/build"
readonly DEPOT_TOOLS_DIR="${BUILD_DIR}/depot_tools"
readonly SKIA_DIR="${BUILD_DIR}/skia"
download_depot_tools() {
echo 'Downloading depot tools...'