How to use telejson - 4 common examples

To help you get started, we’ve selected a few telejson examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github storybookjs / storybook / lib / channel-postmessage / src / index.ts View on Github external
send(event: ChannelEvent): Promise {
    const iframeWindow = this.getWindow();
    if (!iframeWindow) {
      return new Promise((resolve, reject) => {
        this.buffer.push({ event, resolve, reject });
      });
    }

    const data = stringify({ key: KEY, event }, { maxDepth: 15 });

    // TODO: investigate http://blog.teamtreehouse.com/cross-domain-messaging-with-postmessage
    // might replace '*' with document.location ?
    iframeWindow.postMessage(data, '*');
    return Promise.resolve(null);
  }
github storybookjs / storybook / lib / channel-postmessage / src / index.ts View on Github external
private handleEvent(rawEvent: RawEvent): void {
    try {
      const { data } = rawEvent;
      const { key, event } = typeof data === 'string' && isJSON(data) ? parse(data) : data;
      if (key === KEY) {
        logger.debug(`message arrived at ${this.config.page}`, event.type, ...event.args);
        this.handler(event);
      }
    } catch (error) {
      logger.error(error);
      // debugger;
    }
  }
}
github storybookjs / storybook / lib / api / src / lib / store-setup.ts View on Github external
_.fn('set', function(key: string, data: object) {
    return _.set(this._area, this._in(key), stringify(data, { maxDepth: 50 }));
  });
  _.fn('get', function(key: string, alt: string) {
github storybookjs / storybook / lib / api / src / lib / store-setup.ts View on Github external
_.fn('get', function(key: string, alt: string) {
    const value = _.get(this._area, this._in(key));
    return value !== null ? parse(value) : alt || value;
  });
};

telejson

A library for teleporting rich data to another place.

MIT
Latest version published 1 year ago

Package Health Score

77 / 100
Full package analysis