How to use the lz-string.compressToEncodedURIComponent function in lz-string

To help you get started, we’ve selected a few lz-string 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 phiresky / backchannel-prediction / web_vis / ts / client.tsx View on Github external
serialize() {
        return LZString.compressToEncodedURIComponent(JSON.stringify(mobx.toJS({
            playbackPosition: this.playbackPosition,
            followPlayback: this.followPlayback,
            conversation: this.conversation,
            uis: this.uis, // TODO: remove uuids
            zoom: this.zoom,
            //totalTimeSeconds: this.totalTimeSeconds
        })));
    }
    @mobx.action
github source-academy / sicp / nodejs / processingFunctions / processSnippetEpub.js View on Github external
const examples = node.getElementsByTagName("EXAMPLE");
      const exampleArr = [];
      for (let i = 0; examples[i]; i++) {
      	const example = examples[i].firstChild.nodeValue;
	      if (snippetStore[example]) {
	        exampleArr.push("\n\n");
	        exampleArr.push(snippetStore[example].codeStr);
	      } else {
	        missingExampleWarning(example);
	      }
      }
      const exampleStr = exampleArr.join("");

      // make url for source academy link
      const compressed = lzString.compressToEncodedURIComponent(
        reqStr + codeStr + exampleStr
      );
      const chap = "4";
      const ext = "";
      const url =
        sourceAcademyURL +
        "/playground#chap=" +
        chap +
        ext +
        "&prgrm=" +
        compressed;

      const chunks = (codeStr + "\n").match(/^((?:.*?[\r\n]+){1,6})((?:.|\n|\r)*)$/);
      // 6 lines plus rest
      writeTo.push(
        "\n\\begin{lrbox}{\\lstbox}\\begin{lstlisting}[mathescape=true, language=JavaScript]\n"
github crossminer / scava / crossflow / org.eclipse.scava.crossflow.web / lib / elkgraph / editor.js View on Github external
url_parameters_1.setupModelLink(editor, function (event) {
    return {
        compressedContent: LZString.compressToEncodedURIComponent(editor.getValue())
    };
});
// Create the web socket
github zalando-stups / yourturn / client / lib / violation / src / violation / violation.jsx View on Github external
render() {
        let shortURL = window.location.origin + '/violation/v/' + lzw.compressToEncodedURIComponent(JSON.stringify(this.props.params)),
            shareURL = shortURL.length < window.location.href.length ? shortURL : window.location.href,
            selectedViolation = this.state.selectedViolation ?
                                    this.props.fullstopStore.getViolation(this.state.selectedViolation) :
                                    null;
        return  <div>
                    <h2>Violations {this.props.loading ? <small></small> : null}</h2>
                    
                        <div>
                             Copy sharing URL
                        </div>
                    
                    <div style="{{display:">
                        {this.props.error &amp;&amp; this.props.error.message || 'Error'}
                    </div></div>
github Autodesk / react-base-table / website / src / utils / urlHash.js View on Github external
export const replaceState = code => {
  const hash = code ? LZString.compressToEncodedURIComponent(code) : ''

  if (
    typeof URL === 'function' &&
    typeof window.history === 'object' &&
    typeof window.history.replaceState === 'function'
  ) {
    const url = new URL(document.location)
    url.hash = hash
    window.history.replaceState(null, null, url)
  } else {
    document.location.hash = hash
  }
}
github martijnversluis / ChordFiddle / src / utils / string_compression.js View on Github external
export function compress(input) {
  return LZString.compressToEncodedURIComponent(input);
}
github palantir / tslint-playground / src / utils.ts View on Github external
export const encodeUrl = (code: string, config: string) => {
  const toCompress = JSON.stringify({ code, config });
  const compressed = lzString.compressToEncodedURIComponent(toCompress);
  return `?saved=${compressed}`;
};
github seek-oss / playroom / utils / index.js View on Github external
const createUrl = ({ baseUrl, code, themes, widths }) => {
  let path = '';

  if (code || themes || widths) {
    const data = JSON.stringify({
      ...(code ? { code } : {}),
      ...(themes ? { themes } : {}),
      ...(widths ? { widths } : {})
    });

    const compressedData = lzString.compressToEncodedURIComponent(data);
    path = `#?code=${compressedData}`;
  }

  if (baseUrl) {
    const trimmedBaseUrl = baseUrl.replace(/\/$/, '');

    return `${trimmedBaseUrl}/${path}`;
  }

  return path;
};
github brodybits / prettierx / website / playground / urlHash.js View on Github external
export function replace(state) {
  const hash = LZString.compressToEncodedURIComponent(JSON.stringify(state));
  if (
    typeof URL === "function" &&
    typeof history === "object" &&
    typeof history.replaceState === "function"
  ) {
    const url = new URL(location);
    url.hash = hash;
    history.replaceState(null, null, url);
  } else {
    location.hash = hash;
  }
}