@expo/json-file

  • Version 9.0.0
  • Published
  • 36 kB
  • 3 dependencies
  • MIT license

Install

npm i @expo/json-file
yarn add @expo/json-file
pnpm add @expo/json-file

Overview

A module for reading, writing, and manipulating JSON files

Index

Functions

function deleteKey

deleteKey: <TJSONObject extends JSONObject>(
file: string,
key: string,
options?: Options<TJSONObject>
) => TJSONObject;

    function deleteKeyAsync

    deleteKeyAsync: <TJSONObject extends JSONObject>(
    file: string,
    key: string,
    options?: Options<TJSONObject>
    ) => Promise<TJSONObject>;

      function deleteKeys

      deleteKeys: <TJSONObject extends JSONObject>(
      file: string,
      keys: string[],
      options?: Options<TJSONObject>
      ) => TJSONObject;

        function deleteKeysAsync

        deleteKeysAsync: <TJSONObject extends JSONObject>(
        file: string,
        keys: string[],
        options?: Options<TJSONObject>
        ) => Promise<TJSONObject>;

          function getAsync

          getAsync: <
          TJSONObject extends JSONObject,
          K extends keyof TJSONObject,
          DefaultValue
          >(
          file: string,
          key: K,
          defaultValue: DefaultValue,
          options?: Options<TJSONObject>
          ) => Promise<any>;

            function getSync

            getSync: <
            TJSONObject extends JSONObject,
            K extends keyof TJSONObject,
            DefaultValue
            >(
            file: string,
            key: K,
            defaultValue: DefaultValue,
            options?: Options<TJSONObject>
            ) => any;

              function merge

              merge: <TJSONObject extends JSONObject>(
              file: string,
              sources: Partial<TJSONObject> | Partial<TJSONObject>[],
              options?: Options<TJSONObject>
              ) => TJSONObject;

                function mergeAsync

                mergeAsync: <TJSONObject extends JSONObject>(
                file: string,
                sources: Partial<TJSONObject> | Partial<TJSONObject>[],
                options?: Options<TJSONObject>
                ) => Promise<TJSONObject>;

                  function parseJsonString

                  parseJsonString: <TJSONObject extends JSONObject>(
                  json: string,
                  options?: Options<TJSONObject>,
                  fileName?: string
                  ) => TJSONObject;

                    function read

                    read: <TJSONObject extends JSONObject>(
                    file: string,
                    options?: Options<TJSONObject>
                    ) => TJSONObject;

                      function readAsync

                      readAsync: <TJSONObject extends JSONObject>(
                      file: string,
                      options?: Options<TJSONObject>
                      ) => Promise<TJSONObject>;

                        function rewrite

                        rewrite: <TJSONObject extends JSONObject>(
                        file: string,
                        options?: Options<TJSONObject>
                        ) => TJSONObject;

                          function rewriteAsync

                          rewriteAsync: <TJSONObject extends JSONObject>(
                          file: string,
                          options?: Options<TJSONObject>
                          ) => Promise<TJSONObject>;

                            function setAsync

                            setAsync: <TJSONObject extends JSONObject>(
                            file: string,
                            key: string,
                            value: unknown,
                            options?: Options<TJSONObject>
                            ) => Promise<TJSONObject>;

                              function setSync

                              setSync: <TJSONObject extends JSONObject>(
                              file: string,
                              key: string,
                              value: unknown,
                              options?: Options<TJSONObject>
                              ) => TJSONObject;

                                function write

                                write: <TJSONObject extends JSONObject>(
                                file: string,
                                object: TJSONObject,
                                options?: Options<TJSONObject>
                                ) => TJSONObject;

                                  function writeAsync

                                  writeAsync: <TJSONObject extends JSONObject>(
                                  file: string,
                                  object: TJSONObject,
                                  options?: Options<TJSONObject>
                                  ) => Promise<TJSONObject>;

                                    Classes

                                    class JsonFile

                                    class JsonFile<TJSONObject extends JSONObject> {}
                                    • The JsonFile class represents the contents of json file.

                                      It's polymorphic on "JSONObject", which is a simple type representing and object with string keys and either objects or primitive types as values. {[type]}

                                    constructor

                                    constructor(file: string, options?: Options<TJSONObject>);

                                      property deleteKey

                                      static deleteKey: <TJSONObject extends JSONObject>(
                                      file: string,
                                      key: string,
                                      options?: Options<TJSONObject>
                                      ) => TJSONObject;

                                        property deleteKeyAsync

                                        static deleteKeyAsync: <TJSONObject extends JSONObject>(
                                        file: string,
                                        key: string,
                                        options?: Options<TJSONObject>
                                        ) => Promise<TJSONObject>;

                                          property deleteKeys

                                          static deleteKeys: <TJSONObject extends JSONObject>(
                                          file: string,
                                          keys: string[],
                                          options?: Options<TJSONObject>
                                          ) => TJSONObject;

                                            property deleteKeysAsync

                                            static deleteKeysAsync: <TJSONObject extends JSONObject>(
                                            file: string,
                                            keys: string[],
                                            options?: Options<TJSONObject>
                                            ) => Promise<TJSONObject>;

                                              property file

                                              file: string;

                                                property get

                                                static get: <
                                                TJSONObject extends JSONObject,
                                                K extends keyof TJSONObject,
                                                DefaultValue
                                                >(
                                                file: string,
                                                key: K,
                                                defaultValue: DefaultValue,
                                                options?: Options<TJSONObject>
                                                ) => any;

                                                  property getAsync

                                                  static getAsync: <
                                                  TJSONObject extends JSONObject,
                                                  K extends keyof TJSONObject,
                                                  DefaultValue
                                                  >(
                                                  file: string,
                                                  key: K,
                                                  defaultValue: DefaultValue,
                                                  options?: Options<TJSONObject>
                                                  ) => Promise<any>;

                                                    property merge

                                                    static merge: <TJSONObject extends JSONObject>(
                                                    file: string,
                                                    sources: Partial<TJSONObject> | Partial<TJSONObject>[],
                                                    options?: Options<TJSONObject>
                                                    ) => TJSONObject;

                                                      property mergeAsync

                                                      static mergeAsync: <TJSONObject extends JSONObject>(
                                                      file: string,
                                                      sources: Partial<TJSONObject> | Partial<TJSONObject>[],
                                                      options?: Options<TJSONObject>
                                                      ) => Promise<TJSONObject>;

                                                        property options

                                                        options: Options<TJSONObject>;

                                                          property parseJsonString

                                                          static parseJsonString: <TJSONObject extends JSONObject>(
                                                          json: string,
                                                          options?: Options<TJSONObject>,
                                                          fileName?: string
                                                          ) => TJSONObject;

                                                            property read

                                                            static read: <TJSONObject extends JSONObject>(
                                                            file: string,
                                                            options?: Options<TJSONObject>
                                                            ) => TJSONObject;

                                                              property readAsync

                                                              static readAsync: <TJSONObject extends JSONObject>(
                                                              file: string,
                                                              options?: Options<TJSONObject>
                                                              ) => Promise<TJSONObject>;

                                                                property rewrite

                                                                static rewrite: <TJSONObject extends JSONObject>(
                                                                file: string,
                                                                options?: Options<TJSONObject>
                                                                ) => TJSONObject;

                                                                  property rewriteAsync

                                                                  static rewriteAsync: <TJSONObject extends JSONObject>(
                                                                  file: string,
                                                                  options?: Options<TJSONObject>
                                                                  ) => Promise<TJSONObject>;

                                                                    property set

                                                                    static set: <TJSONObject extends JSONObject>(
                                                                    file: string,
                                                                    key: string,
                                                                    value: unknown,
                                                                    options?: Options<TJSONObject>
                                                                    ) => TJSONObject;

                                                                      property setAsync

                                                                      static setAsync: <TJSONObject extends JSONObject>(
                                                                      file: string,
                                                                      key: string,
                                                                      value: unknown,
                                                                      options?: Options<TJSONObject>
                                                                      ) => Promise<TJSONObject>;

                                                                        property write

                                                                        static write: <TJSONObject extends JSONObject>(
                                                                        file: string,
                                                                        object: TJSONObject,
                                                                        options?: Options<TJSONObject>
                                                                        ) => TJSONObject;

                                                                          property writeAsync

                                                                          static writeAsync: <TJSONObject extends JSONObject>(
                                                                          file: string,
                                                                          object: TJSONObject,
                                                                          options?: Options<TJSONObject>
                                                                          ) => Promise<TJSONObject>;

                                                                            method deleteKey

                                                                            deleteKey: (key: string, options?: Options<TJSONObject>) => TJSONObject;

                                                                              method deleteKeyAsync

                                                                              deleteKeyAsync: (
                                                                              key: string,
                                                                              options?: Options<TJSONObject>
                                                                              ) => Promise<TJSONObject>;

                                                                                method deleteKeys

                                                                                deleteKeys: (keys: string[], options?: Options<TJSONObject>) => TJSONObject;

                                                                                  method deleteKeysAsync

                                                                                  deleteKeysAsync: (
                                                                                  keys: string[],
                                                                                  options?: Options<TJSONObject>
                                                                                  ) => Promise<TJSONObject>;

                                                                                    method get

                                                                                    get: <K extends keyof TJSONObject, TDefault extends TJSONObject[K]>(
                                                                                    key: K,
                                                                                    defaultValue: TDefault,
                                                                                    options?: Options<TJSONObject>
                                                                                    ) => Defined<TJSONObject[K]> | TDefault;

                                                                                      method getAsync

                                                                                      getAsync: <K extends keyof TJSONObject, TDefault extends TJSONObject[K]>(
                                                                                      key: K,
                                                                                      defaultValue: TDefault,
                                                                                      options?: Options<TJSONObject>
                                                                                      ) => Promise<Defined<TJSONObject[K]> | TDefault>;

                                                                                        method merge

                                                                                        merge: (
                                                                                        sources: Partial<TJSONObject> | Partial<TJSONObject>[],
                                                                                        options?: Options<TJSONObject>
                                                                                        ) => Promise<TJSONObject>;

                                                                                          method mergeAsync

                                                                                          mergeAsync: (
                                                                                          sources: Partial<TJSONObject> | Partial<TJSONObject>[],
                                                                                          options?: Options<TJSONObject>
                                                                                          ) => Promise<TJSONObject>;

                                                                                            method parseJsonString

                                                                                            parseJsonString: (json: string, options?: Options<TJSONObject>) => TJSONObject;

                                                                                              method read

                                                                                              read: (options?: Options<TJSONObject>) => TJSONObject;

                                                                                                method readAsync

                                                                                                readAsync: (options?: Options<TJSONObject>) => Promise<TJSONObject>;

                                                                                                  method rewrite

                                                                                                  rewrite: (options?: Options<TJSONObject>) => TJSONObject;

                                                                                                    method rewriteAsync

                                                                                                    rewriteAsync: (options?: Options<TJSONObject>) => Promise<TJSONObject>;

                                                                                                      method set

                                                                                                      set: (
                                                                                                      key: string,
                                                                                                      value: unknown,
                                                                                                      options?: Options<TJSONObject>
                                                                                                      ) => TJSONObject;

                                                                                                        method setAsync

                                                                                                        setAsync: (
                                                                                                        key: string,
                                                                                                        value: unknown,
                                                                                                        options?: Options<TJSONObject>
                                                                                                        ) => Promise<TJSONObject>;

                                                                                                          method write

                                                                                                          write: (object: TJSONObject, options?: Options<TJSONObject>) => TJSONObject;

                                                                                                            method writeAsync

                                                                                                            writeAsync: (
                                                                                                            object: TJSONObject,
                                                                                                            options?: Options<TJSONObject>
                                                                                                            ) => Promise<TJSONObject>;

                                                                                                              Interfaces

                                                                                                              interface JSONArray

                                                                                                              interface JSONArray extends Array<JSONValue> {}

                                                                                                                interface JSONObject

                                                                                                                interface JSONObject {}

                                                                                                                  index signature

                                                                                                                  [key: string]: JSONValue | undefined;

                                                                                                                    Type Aliases

                                                                                                                    type JSONValue

                                                                                                                    type JSONValue = boolean | number | string | null | JSONArray | JSONObject;

                                                                                                                      Package Files (1)

                                                                                                                      Dependencies (3)

                                                                                                                      Dev Dependencies (5)

                                                                                                                      Peer Dependencies (0)

                                                                                                                      No peer dependencies.

                                                                                                                      Badge

                                                                                                                      To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                      You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@expo/json-file.

                                                                                                                      • Markdown
                                                                                                                        [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@expo/json-file)
                                                                                                                      • HTML
                                                                                                                        <a href="https://www.jsdocs.io/package/@expo/json-file"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>