0.0.1 • Published 5 years ago

trailhead v0.0.1

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

Compatibility

Requires Typescript 4.0+ and the Proxy API. You can check browser compatibility for Proxies at caniuse.com/proxy.

Usage

import { trailhead } from 'trailhead';

type Data = {
  firstName: string;
  array: string[];
  nest: {
    nest: {
      firstName: string;
    };
  };
  arrayObject: {
    firstName: string;
    lastName: string;
  }[];
};

const test = trailhead<Data>();

console.log(test); // => { __path: [] }
console.log(test.firstName); // => { __path: ["firstName"] }
console.log(test.array[5]); // => { __path: ["array", 5] }
console.log(test.nest.nest.firstName); // => { __path: ["nest", "nest", "firstName"] }
console.log(test.arrayObject); // => { __path: ["arrayObject"] }
console.log(test.arrayObject[5]); // => { __path: ["arrayObject", 5, "firstName"] }
console.log(test.arrayObject[5].firstName); // => { __path: ["arrayObject", 5, "firstName"] }