Socket
Socket
Sign inDemoInstall

shadow.js

Package Overview
Dependencies
4
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    shadow.js

"# My project's README"


Version published
Weekly downloads
4
Maintainers
1
Install size
549 kB
Created
Weekly downloads
 

Readme

Source

API

get(key:string)

Get the current value and all other remaining value

watch(key:string)

Get any new values that are set

also(...keys:string[])

If you want to watch more properties. You can do that

Examples as Test Cases

import "rxjs/add/operator/take"
import "rxjs/add/operator/finally"
import {expect} from "chai"
import { Shadow } from 'shadow.js';

describe("Shadow",()=>{

    function setup(){
        return Shadow.create({
            name:"Shavyg",
            age:27
        })
    }

    let person = setup();

    beforeEach(()=>person=setup());


    //you can watch for a propert change on anything

    it("Should be able to watch shaded properties",(done)=>{
        Shadow(person).watch("name").subscribe(()=>{
            done();
        });
        person.name = "Pizza";
        person.age = 1000;
    })




    it("Should be able to get shaded properties",(done)=>{
        Shadow(person).get("name").take(2).finally(done).subscribe();
        person.name = "Pizza";
        person.age = 1000;
    })


    it("should be able to shadow new properties",(done)=>{

        Shadow(person).also("race")

        Shadow(person).watch("race").take(1).subscribe(()=>{
            done();
        });

        (person as any).race = "super";
    })


    afterEach(()=>{
        Shadow(person).clear();
    })

})

FAQs

Last updated on 21 Jul 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc