getInstance in jest code example

Example 1: weakset in es6

/*
WeakSet() is as same as Set()
Similarities:
	1.WeakSet() has all methods that Set() has.
    2.WeakSet() Donot contain Duplicate Values as Set().
Differences:
    3.WeakSet Values are Non Enumerated
    4.WeakSet Value can only be Empty Objects
*/

var weak = new WeakSet();
weak.add({});
var a={};
weak.add(a);

Example 2: Parallax.js wrapper for react

import React, { Component } from 'react'
import Parallax from 'parallax-js' // Now published on NPM

class ParallaxComponent extends Component {
  componentDidMount() {
    this.parallax = new Parallax(this.scene)
  }
  componentWillUnmount() {
    this.parallax.disable()
  }
  render() {
    render (
      <ul ref={el => this.scene = el}>
        <li className="layer" dataDepth="0.00">
          <img src="layer1.png"/>
        </li>
        <li className="layer" dataDepth="0.50">
          <img src="layer2.png"/>
        </li>
        <li className="layer" dataDepth="1.00">
          <img src="layer3.png"/>
        </li>
      </ul>
    )
  }
}

Tags:

Go Example