Skip to content

Instantly share code, notes, and snippets.

View iShawnWang's full-sized avatar
🤗
2333

Shawn Wang iShawnWang

🤗
2333
View GitHub Profile
@iShawnWang
iShawnWang / optional.js
Last active April 28, 2022 09:13
ES6 Proxy Optional Chain
const optional = (srcObj) => {
return new Proxy(() => {}, {
apply: () => {
return srcObj
},
get: (__, prop) => {
if (srcObj && srcObj.hasOwnProperty(prop)) {
return optional(srcObj[prop])
} else {
return optional(undefined)
@iShawnWang
iShawnWang / immer.js
Created April 28, 2022 09:40
ES6 Proxy Immer.js
const PROXY_STATE = Symbol('immer-proxy-state')
class State {
srcObj
copy
touched
parent
constructor(srcObj, parent) {
this.srcObj = srcObj

Track Color Platte

Assign Track Color by Frequencies

Track Color
Kick #FF364D #FF364D
Snare #1AA1FF #1AA1FF
Clap #D68EA4 #D68EA4
Open HiHat #03C539 #03C539
@iShawnWang
iShawnWang / launch.json
Last active May 8, 2023 05:55
VSCode + tsx + Auto Attach Debugger : https://github.com/esbuild-kit/tsx
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Run current script",
"runtimeExecutable": "npx",
"runtimeArgs": ["tsx"],
"program": "${file}",
@iShawnWang
iShawnWang / vtrack.vue
Last active November 1, 2023 07:26
v-track
// Sample Usage
<template>
<button v-track="xxxEvent" />
<input v-track="xxxEvent" />
<input v-track="() => new Date().getTime()" />
</template>
<script>
// v-track directive
Vue.directive("track", {