Skip to main content
Deno 2 is finally here ๐ŸŽ‰๏ธ
Learn more
Module

x/denops_std/function/vim/mod.ts>js_encode

๐Ÿ“š Standard module for denops.vim
Go to Latest
function js_encode
import { js_encode } from "https://deno.land/x/denops_std@v6.3.0/function/vim/mod.ts";

This is similar to json_encode() with these differences:

  • Object key names are not in quotes.
  • v:none items in an array result in an empty item between commas. For example, the Vim object: [1,v:none,{"one":1},v:none] Will be encoded as: [1,,{one:1},,] While json_encode() would produce: [1,null,{"one":1},null] This encoding is valid for JavaScript. It is more efficient than JSON, especially when using an array with optional items.

Can also be used as a method:

GetObject()->js_encode()

Parameters

denops: Denops
expr: unknown

Returns

Promise<string>