{"id":14978534,"url":"https://github.com/noahweasley/node-user-settings","last_synced_at":"2026-02-08T16:32:19.652Z","repository":{"id":45761411,"uuid":"514422451","full_name":"noahweasley/Node-User-Settings","owner":"noahweasley","description":"A universal but simple node library to implement user settings, built to work with Electron.js with little or no configurations","archived":false,"fork":false,"pushed_at":"2023-09-23T14:04:25.000Z","size":331,"stargazers_count":1,"open_issues_count":4,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-13T10:36:33.038Z","etag":null,"topics":["app","data","electronjs","json","nodejs","persist","settings","storage","sync","user"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/node-user-settings","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/noahweasley.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"buymeacoffee":"www.buymeacoffee.com/noahweasley"}},"created_at":"2022-07-15T22:40:23.000Z","updated_at":"2023-10-05T22:23:34.000Z","dependencies_parsed_at":"2025-02-13T10:43:07.005Z","dependency_job_id":null,"html_url":"https://github.com/noahweasley/Node-User-Settings","commit_stats":null,"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noahweasley%2FNode-User-Settings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noahweasley%2FNode-User-Settings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noahweasley%2FNode-User-Settings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/noahweasley%2FNode-User-Settings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/noahweasley","download_url":"https://codeload.github.com/noahweasley/Node-User-Settings/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242900939,"owners_count":20203863,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["app","data","electronjs","json","nodejs","persist","settings","storage","sync","user"],"created_at":"2024-09-24T13:57:51.924Z","updated_at":"2026-02-08T16:32:19.625Z","avatar_url":"https://github.com/noahweasley.png","language":"JavaScript","funding_links":["www.buymeacoffee.com/noahweasley"],"categories":[],"sub_categories":[],"readme":"# Node User Settings\n\n![License](https://img.shields.io/npm/l/node-user-settings?color=yellow) ![Release](https://img.shields.io/github/v/release/noahweasley/node-user-settings?color=informational\u0026include_prereleases) ![NPM Downloads](https://img.shields.io/npm/dw/node-user-settings)\n\nA universal but simple node library to implement user settings, but originally built to work with Electron.js.\n\n## Features 🌺\n\n- Code in your own style\n- Easy to setup and use\n- Synchronous functions available\n- Asynchronous functions available\n- Callback-based functions available\n\n## Getting Started ☕\n\n### Installation 💻\n\n---\n\n```\nnpm i node-user-settings --save\n```\n\n### API Usage 📝\n\n---\n\n### Please Note 🚨\n\n- For now, callback-based methods naming are weird, I know. I am going to fix it in a major release; in the future.\n\n- You can specify an optional filename in which settings would be saved or retrieved. An optional filename isn't required and can be left blank.\n\n- A new preference file would be created after using the `optionalFileName` argument, with the persisted preference in it.\n\n- Adding a sync as suffix to the promise-based functions, provides you with it's synchronous alternatives.\n\n- `preferenceFileName` is no longer deprecated as of v1.5.0. Use `preferenceDir`, `fileName` and `fileExt` to set the file name to be used to persist settings, if you want to split the preference directory, filename and extension.\n\n- Specifying only `preferenceFileName` in `options` is the same as calling `settings.setDefaultPreferenceFilePath()`\n\n- Leaving `fileExt` config option blank but setting a `fileName`, results in a file with the `.json` file extension.\n\n- It is recommended that you only initialize the API once and then pass the initialized instance around using **Dependency Injection**. Even though you don't do this, it's still possible that the API would work as you want because Node JS automatically caches a module after **requiring** them. But again, I wouldn't recommend you do that!\n\n## Setup and Initialization 🛠️\n\nInitialization using exported method\n\n```javascript\nconst settings = require(\"node-user-settings)([options]);\n```\n\nIn case you don't want to initialize `options` using exported method, initialize it this way\n\n```javascript\nconst settings = require(\"node-user-settings\").defaults;\n```\n\n**Please note**: You must call `settings.setDefaultPreferenceFilePath()` after using `.defaults`, else an error would be thrown\n\n### Options\n\n#### Type: `Object`\n\n### Keys\n\n#### `preferenceFileName`\n\nThe filename (with extension) used to persist preference\n\n#### `preferenceFileDir`\n\nThe directory used to persist preference\n\n#### `fileName`\n\nThe file name (without extension) used to persist preference\n\n#### `fileExt`\n\nThe file extension of the file used to persist preference\n\n**Example**\n\nFor Non-Electron JS users 💡\n\n---\n\n#### Splitting paths into different units\n\n```javascript\n// preferenceFileName is optional, it defaults to a Settings.json file\n\nconst settings = require(\"node-user-settings\")({\n  preferenceFileDir: \"path/to/save/preference\",\n  preferenceFileName: \"Settings.json\",\n  fileName: \"Settings\",\n  fileExt: \"json\"\n});\n```\n\n#### Merging paths into a single unit\n\n```javascript\n// using only preferenceFileName, it is required for you to input the full path to the file\n\nconst settings = require(\"node-user-settings\")({\n  preferenceFileName: \"path/to/save/preference/Settings.json\"\n});\n```\n\nFor Electron JS Users 💡\n\n---\n\n#### Splitting paths into different units\n\n```javascript\n// preferenceFileName is optional, it defaults to a Settings.json file\n\nconst { app } = require(\"electron\");\nconst { join } = require(\"path\");\n\nconst settings = require(\"node-user-settings\")({\n  /* this is the recommended path to persist preference */\n  preferenceFileDir: join(app.getPath(\"userData\"), \"User\", \"Preferences\"),\n  /* preferenceFileName is optional, it defaults to a Settings.json file */\n  preferenceFileName: \"Settings.json\",\n  fileName: \"Settings\",\n  fileExt: \"json\"\n});\n```\n\n#### Merging paths into a single unit\n\n```javascript\nconst { app } = require(\"electron\");\nconst { join } = require(\"path\");\n\n// using only preferenceFileName, it is required for you to input the full path to the file\n\nconst settings = require(\"node-user-settings\")({\n  /* this is the recommended path to persist preference */\n  preferenceFileName: join(app.getPath(\"userData\"), \"User\", \"Preferences\", \"Settings.json\")\n});\n```\n\nThe _settings_ variable where module was imported and stored, is what would be used to call the following methods listed below\n\n## General Utility Method 💡\n\n### ` getDefaultPreferenceFilePath()`\n\nGets the default save path to the preference\n\n#### Returns\n\n_A String_. The default save path to the preference\n\n**Example**\n\n```javascript\nconst path = settings.getDefaultPreferenceFilePath();\nconsole.log(path);\n```\n\n### `  getTempPreferenceOptionalFilePath()`\n\nGets the optional save path to the preference, if an optional file path was previously specified\n\n**Please note**: You mostly never need to use this method at all! Never include it in production code,\nuse only in development mode\n\n#### Returns\n\n_A String_. The temporary save path to the preference\n\n**Example**\n\n```javascript\nconst tmpPath = settings.getTempPreferenceOptionalFilePath();\nconsole.log(tmpPath);\n```\n\n### ` setDefaultPreferenceFilePath(filePath)`\n\nSets the default path to the preference file\n\n_Note_: This method is synchronous, and it is to be used in initialization only. Even though you tried to re-set the default save path, it would throw an error, so you should use it to explicitly set the default preference file path immediately after importing or _requiring_ the module\n\n### Parameter\n\n---\n\n### filePath\n\n#### Type: `String`\n\nThe file path to persist preference\n\n#### Returns\n\n_A String_. The default save path to the preference\n\n**Example**\n\n```javascript\nconst path = settings.setDefaultPreferenceFilePath(\"path/to/save/preference\");\nconsole.log(path);\n```\n\n## Promise-based Method 💡\n\n### `getState(key, defaultValue, optionalFileName)`\n\nGets a value asynchronously\n\n### Parameter\n\n---\n\n### key\n\n#### Type: `String`\n\nThe key in the preference in which it's value would be retrieved\n\n### optionalFileName\n\n#### Type:`String`\n\nAn optional filename used to persist the settings. This can be left _null_\n\n### defaultValue\n\n#### Type: `String`\n\nA default value to be used if that key has never been set\n\n#### Returns\n\n_Promise that resolves to a string_. The value which was mapped to the key specified\n\n**Example**\n\n```javascript\nconst value = await settings.getState(\"key\", \"a-default-value\" optionalFileName);\nconsole.log(value);\n```\n\n### `setState(key, value, optionalFileName)`\n\nSets a value asynchronously\n\n### Parameter\n\n---\n\n### key\n\n#### Type: `String`\n\nThe key in the preference in which it's value would be retrieved\n\n### value\n\n#### Type: `String`\n\nThe value to be set and mapped to the key\n\n### optionalFileName\n\n#### Type: `String`\n\nAn optional filename used to persist the settings. This can be left _null_\n\n#### Returns\n\n_Promise that resolves to a Boolean_. indicating if the operation was successful or not\n\n**Example**\n\n```javascript\nconst isSet = await settings.setState(\"key\", \"value\", optionalFileName);\nconsole.log(`Is value set: ${isSet}`);\n```\n\n### `setStates(states, optionalFileName)`\n\nSets multiple value simultaneously and asynchronously\n\n### Parameter\n\n---\n\n### states\n\n#### Type: `Object`\n\nA map with the key-value pair to be persisted\n\n### optionalFileName\n\n#### Type: `String`\n\nAn optional filename used to persist the settings. This can be left _null_\n\n#### Returns\n\n_A Promise that resolves an Array_. A list of all the values that were persisted / set\n\n**Example**\n\n```javascript\n// the states to be persisted\nconst map = {\n  moduleName: \"node-user-settings\",\n  version: \"1.0.0\",\n  author: \"noahweasley\"\n};\n\nlet persisted = await settings.setStates(map, optionalFileName);\nconsole.log(`This values were set: ${Array.toString(persisted)}`);\n```\n\n### `getStates(states, optionalFileName)`\n\nGets multiple value simultaneously and asynchronously\n\n### Parameter\n\n---\n\n### states\n\n#### Type: `Array`\n\nAn array of keys of which values would be retrieved\n\n### optionalFileName\n\n#### Type: `String`\n\nAn optional filename used to persist the settings. This can be left _null_\n\n#### Returns\n\n_A Promise that resolves an Array_. A list of all the values that were retrieved\n\n**Example**\n\n```javascript\n// the states to be retrieved\nlet states = [\"key1\", \"key2\", \"key3\"];\nlet [value1, value2, value3] = await settings.getStates(states, optionalFileName);\n```\n\n### `hasKey(key, optionalFileName)`\n\nAsynchronously checks if a key exists\n\n### Parameter\n\n---\n\n### key\n\n#### Type: `String`\n\nThe key in the preference in which it's value would be checked for it's existence\n\n### optionalFileName\n\n#### Type: `String`\n\nAn optional filename used to do the check. This can be left _null_\n\n#### Returns\n\n_Promise that resolves to a Boolean_. indicating if the key exists in the persisted preference\n\n**Example**\n\n```javascript\nlet hasKey = await settings.hasKey(\"key\", optionalFileName);\nconsole.log(`Is this key available: ${hasKey ? `YES` : `NO`}`);\n```\n\n### `deleteKey(key, optionalFileName)`\n\nAsynchronously deletes a single entry\n\n### Parameter\n\n---\n\n### key\n\n#### Type: `String`\n\nThe key in the preference in which it's value would be deleted\n\n### optionalFileName\n\n#### Type: `String`\n\nAn optional filename used to persist the settings. This can be left _null_\n\n#### Returns\n\n_Promise that resolves to a Boolean_. indicating if the key was successfully deleted\n\n**Example**\n\n```javascript\nlet isDeleted = await settings.deleteKey(\"key\", optionalFileName);\nconsole.log(`Is key deleted? ${isDeleted ? `YES` : `NO`}`);\n```\n\n### `deleteFile(optionalFileName)`\n\nAsynchronously deletes the preference file\n\n### Parameter\n\n---\n\n### optionalFileName\n\n#### Type: `String`\n\nAn optional filename in which the corresponding file would be deleted. This can be left _null_\n\n#### Returns\n\n_Promise that resolves to a Boolean_. indicating if the file was successfully deleted\n\n**Example**\n\n```javascript\nlet isDeleted = await settings.deleteFile(optionalFileName);\nconsole.log(`Is file deleted? ${isDeleted ? `YES` : `NO`}`);\n```\n\n### `serialize(preferenceOb, optionalFileName)`\n\nAsynchronously replaces all data in preference\n\n### Parameter\n\n---\n\n### preferenceOb\n\n#### Type: `Object`\n\nA JSON object to be serialized and persisted\n\n### optionalFileName\n\n#### Type: `String`\n\nAn optional filename used to persist the settings. This can be left _null_\n\n#### Returns\n\n_A Boolean_. indicating if it was persisted successfully\n\n**Example**\n\n```javascript\nconst mockData = {\n  moduleName: \"node-user-settings\",\n  version: \"1.0.0\",\n  author: \"noahweasley\"\n};\n\nconst isPersisted = await settings.serialize(mockData, optionalFileName);\nconsole.log(`Is data changed ? ${isPersisted ? `YES` : `NO`}`);\n```\n\n### `deserialize(optionalFileName)`\n\nAsynchronously retrieves all the data in preference\n\n### Parameter\n\n---\n\n### optionalFileName\n\n#### Type: `String`\n\nAn optional filename used to persist the settings. This can be left _null_\n\n#### Returns\n\n_Promise that resolves to A String_. The persisted object as it exists in preference\n\n**Example**\n\n```javascript\nconst data = await settings.deserialize(optionalFileName);\nconsole.log(data);\n```\n\n## Callback-based Method 💡\n\n### `getState_c(key, defaultValue, optionalFileName, callbackfn)`\n\nGets a value asynchronously\n\n### Parameter\n\n---\n\n### key\n\n#### Type: `String`\n\nThe key in the preference in which it's value would be retrieved\n\n### defaultValue\n\n#### Type: `String`\n\nA default value to be used if that key has never been set\n\n### optionalFileName\n\n#### Type: `String`\n\nAn optional filename used to persist the settings. This can be left _null_\n\n### callbackfn\n\n#### Type: `Function`\n\nA Node-Js qualified callback with any error that occurred as the first argument and a String as the second argument, representing the value which was mapped to the key specified\n\n**Example**\n\n```javascript\nsettings.getState_c(\"key\", \"a-default-value\", optionalFileName, function (err, value) {\n  if (err) console.log(err);\n  else console.log(value);\n});\n```\n\n### `setState_c(key, value, optionalFileName, callbackfn)`\n\nSets a value asynchronously\n\n### Parameter\n\n---\n\n### key\n\n#### Type: `String`\n\nThe key in the preference in which it's value would be set\n\n### value\n\n#### Type: `String`\n\nThe value to be set and mapped to the key\n\n### optionalFileName\n\n#### Type: `String`\n\nAn optional filename used to persist the settings. This can be left _null_\n\n### callbackfn\n\n#### Type: `Function`\n\nA Node-Js qualified callback with any error that occurred as the first argument and a Boolean as the second argument, indicating if the operation was successful or not\n\n**Example**\n\n```javascript\nsettings.setState_c(\"key\", \"value\", optionalFileName, function (err, isSet) {\n  if (err) console.error(err);\n  else console.log(`Is value set: ${isSet}`);\n});\n```\n\n### `setStates_c(states, optionalFileName, callbackfn)`\n\nSets multiple value simultaneously and asynchronously\n\n### Parameter\n\n---\n\n### states\n\n#### Type: `Object`\n\nA map with the key-value pair to be persisted\n\n### optionalFileName\n\n#### Type: `String`\n\nAn optional filename used to persist the settings. This can be left _null_\n\n### callbackfn\n\n#### Type: `Function`\n\nA Node-Js qualified callback with any error that occurred as the first argument and an Array as the second argument, representing a list of all the values that were persisted / set\n\n**Example**\n\n```javascript\n// the states to be persisted\nconst map = {\n  moduleName: \"node-user-settings\",\n  version: \"1.0.0\",\n  author: \"noahweasley\"\n};\n\nsettings.setStates_c(map, optionalFileName, function (err, persisted) {\n  if (err) console.error(err);\n  else console.log(`This values were set: ${Array.toString(persisted)}`);\n});\n```\n\n### `getStates_c(states, optionalFileName, callbackfn)`\n\nGets multiple value simultaneously and asynchronously\n\n### Parameter\n\n---\n\n### states\n\n#### Type: `Array`\n\nAn array of keys of which values would be retrieved\n\n### optionalFileName\n\n#### Type: `String`\n\nAn optional filename used to persist the settings. This can be left _null_\n\n### callbackfn\n\n#### Type: `Function`\n\nA Node-Js qualified callback with any error that occurred as the first argument and an Array as the second argument, representing list of all the values that were retrieved\n\n**Example**\n\n```javascript\n// the states to be retrieved\nlet states = [\"key1\", \"key2\", \"key3\"];\nsettings.getStates_c(states, optionalFileName, function (err, values) {\n  let [value1, value2, value3] = values;\n  // do something with this array of values\n});\n```\n\n### `hasKey_c(key, optionalFileName, callbackfn)`\n\nAsynchronously checks if a key exists\n\n### Parameter\n\n---\n\n### key\n\n#### Type: `String`\n\nThe key in the preference in which it's value would be checked for it's existence\n\n### optionalFileName\n\n#### Type: `String`\n\nAn optional filename used to do the check. This can be left _null_\n\n### callbackfn\n\n#### Type: `Function`\n\nA Node-Js qualified callback with any error that occurred as the first argument and a Boolean as the second argument, indicating if the key exists in the persisted preference\n\n**Example**\n\n```javascript\nsettings.hasKey_c(\"key\", optionalFileName, function (err, hasKey) {\n  if (err) console.error(err);\n  else console.log(`Is this key available: ${hasKey ? `YES` : `NO`}`);\n});\n```\n\n### `deleteKey_c(key, optionalFileName, callbackfn)`\n\nAsynchronously deletes a single entry\n\n### Parameter\n\n---\n\n### key\n\n#### Type: `String`\n\nThe key in the preference in which it's value would be deleted\n\n### optionalFileName\n\n#### Type: `String`\n\nAn optional filename used to persist the settings. This can be left _null_\n\n### callbackfn\n\n#### Type: `Function`\n\nA Node-Js qualified callback with any error that occurred as the first argument and a Boolean as the second argument, indicating if the key was successfully deleted\n\n**Example**\n\n```javascript\nsettings.deleteKey_c(\"key\", optionalFileName, function (err, isDeleted) {\n  if (err) console.error(err);\n  else console.log(`Is key deleted? ${isDeleted ? `YES` : `NO`}`);\n});\n```\n\n### `deleteFile_c(optionalFileName, callbackfn)`\n\nAsynchronously deletes the preference file\n\n### Parameter\n\n---\n\n### optionalFileName\n\n#### Type: `String`\n\nAn optional filename in which the corresponding file would be deleted. This can be left _null_\n\n### callbackfn\n\n#### Type: `Function`\n\nA Node-Js qualified callback with any error that occurred as the first argument and a Boolean as the second argument, indicating if the file was successfully deleted\n\n**Example**\n\n```javascript\nsettings.deleteFile_c(optionalFileName, function (err, isDeleted) {\n  if (err) console.error(err);\n  else console.log(`Is file deleted? ${isDeleted ? `YES` : `NO`}`);\n});\n```\n\n### `serialize_c(preferenceOb, optionalFileName, callbackfn)`\n\nAsynchronously replaces all data in preference\n\n### Parameter\n\n---\n\n### preferenceOb\n\n#### Type: `Object`\n\nA JSON object to be serialized and persisted\n\n### optionalFileName\n\n#### Type: `String`\n\nAn optional filename used to persist the settings. This can be left _null_\n\n### callbackfn\n\n#### Type: `Function`\n\nA Node-Js qualified callback with any error that occurred as the first argument and a Boolean as the second argument, indicating if the file was successfully persisted\n\n**Example**\n\n```javascript\nconst mockData = {\n  moduleName: \"node-user-settings\",\n  version: \"1.0.0\",\n  author: \"noahweasley\"\n};\n\nsettings.serialize_c(mockData, optionalFileName, function (err, isPersisted) {\n  if (err) console.error(err);\n  else console.log(`Is data changed ? ${isPersisted ? `YES` : `NO`}`);\n});\n```\n\n### `deserialize_c(optionalFileName, callbackfn)`\n\nAsynchronously retrieves all the data in preference\n\n### Parameter\n\n---\n\n### optionalFileName\n\n#### Type: `String`\n\nAn optional filename used to persist the settings. This can be left _null_\n\n### callbackfn\n\n#### Type: `Function`\n\nA Node-Js qualified callback with any error that occurred as the first argument and a String as the second argument, representing the data that was deserialized and retrieved\n\n**Example**\n\n```javascript\nsettings.deserialize_c(optionalFileName, function (err, data) {\n  if (err) console.error(err);\n  else console.log(data);\n});\n```\n\n## Synchronous Method 💡\n\n### `getStateSync(key, defaultValue, optionalFileName)`\n\nGets a value synchronously\n\n### Parameter\n\n---\n\n### key\n\n#### Type: `String`\n\nThe key in the preference in which it's value would be retrieved\n\n### defaultValue\n\nThe default value to be retrieved if that key has never been set\n\n#### Type: `String`\n\nThe key in the preference in which it's value would be retrieved\n\n### optionalFileName\n\n#### Type: `String`\n\nAn optional filename used to persist the settings. This can be left _null_\n\n#### Returns\n\n_A String_. The value which was mapped to the key specified\n\n**Example**\n\n```javascript\nconst value = settings.getStateSync(\"key\", \"a-default-value\", optionalFileName);\nconsole.log(value);\n```\n\n### `setStateSync(key, optionalFileName)`\n\nSets a value synchronously\n\n### Parameter\n\n---\n\n### key\n\n#### Type: `String`\n\nThe key in the preference in which it's value would be retrieved\n\n### value\n\n#### Type: `String`\n\nThe value to be set and mapped to the key\n\n### optionalFileName\n\n#### Type: `String`\n\nAn optional filename used to persist the settings. This can be left _null_\n\n#### Returns\n\n_A Boolean_. indicating if the operation was successful or not\n\n**Example**\n\n```javascript\nconst isSet = settings.setStateSync(\"key\", \"value\", optionalFileName);\nconsole.log(`Is value set: ${isSet}`);\n```\n\n### `setStatesSync(states, optionalFileName)`\n\nSets multiple value simultaneously and synchronously\n\n### Parameter\n\n---\n\n### states\n\n#### Type: `Object`\n\nA map with the key-value pair to be persisted\n\n### optionalFileName\n\n#### Type: `String`\n\nAn optional filename used to persist the settings. This can be left _null_\n\n#### Returns\n\n_An Array_. A list of all the values that were persisted / set\n\n**Example**\n\n```javascript\n// the states to be persisted\nconst map = {\n  moduleName: \"node-user-settings\",\n  version: \"1.0.0\",\n  author: \"noahweasley\"\n};\n\nlet persisted = settings.setStatesSync(map, optionalFileName);\nconsole.log(`This values were set: ${Array.toString(persisted)}`);\n```\n\n### `getStatesSync(states, optionalFileName)`\n\nGets multiple value simultaneously and synchronously\n\n### Parameter\n\n---\n\n### states\n\n#### Type: `Array`\n\nAn array of keys of which values would be retrieved\n\n### optionalFileName\n\n#### Type: `String`\n\nAn optional filename used to persist the settings. This can be left _null_\n\n#### Returns\n\n_An Array_. A list of all the values that were retrieved\n\n**Example**\n\n```javascript\n// the states to be retrieved\nlet states = [\"key1\", \"key2\", \"key3\"];\nlet [value1, value2, value3] = settings.getStatesSync(states, optionalFileName);\n```\n\n### `hasKeySync(key, optionalFileName)`\n\nSynchronously checks if a key exists\n\n### Parameter\n\n---\n\n### key\n\n#### Type: `String`\n\nThe key in the preference in which it's value would be checked for it's existence\n\n### optionalFileName\n\n#### Type: `String`\n\nAn optional filename used to do the check. This can be left _null_\n\n#### Returns\n\n_A Boolean_. indicating if the key exists in the persisted preference\n\n**Example**\n\n```javascript\nlet hasKey = settings.hasKeySync(\"key\", optionalFileName);\nconsole.log(`Is this key available: ${hasKey ? `YES` : `NO`}`);\n```\n\n### `deleteKeySync(key, optionalFileName)`\n\nSynchronously deletes a single entry\n\n### Parameter\n\n---\n\n### key\n\n#### Type: `String`\n\nThe key in the preference in which it's value would deleted\n\n### optionalFileName\n\n#### Type: `String`\n\nAn optional filename used to persist the settings. This can be left _null_\n\n#### Returns\n\n_A Boolean_. indicating if the key was successfully deleted\n\n**Example**\n\n```javascript\nlet isDeleted = settings.deleteKeySync(\"key\", optionalFileName);\nconsole.log(`Is key deleted? ${isDeleted ? `YES` : `NO`}`);\n```\n\n### `deleteFileSync(optionalFileName)`\n\nSynchronously deletes the preference file\n\n### Parameter\n\n---\n\n### optionalFileName\n\n#### Type: `String`\n\nAn optional filename in which the corresponding file would be deleted. This can be left _null_\n\n#### Returns\n\n_A Boolean_. indicating if the file was successfully deleted\n\n**Example**\n\n```javascript\nlet isDeleted = settings.deleteFileSync(optionalFileName);\nconsole.log(`Is file deleted? ${isDeleted ? `YES` : `NO`}`);\n```\n\n### `serializeSync(preferenceOb, optionalFileName)`\n\nSynchronously replaces all data in preference\n\n### Parameter\n\n---\n\n### preferenceOb\n\n#### Type: `Object`\n\nA JSON object to be serialized and persisted\n\n### optionalFileName\n\n#### Type: `String`\n\nAn optional filename used to persist the settings. This can be left _null_\n\n**Example**\n\n```javascript\nconst mockData = {\n  moduleName: \"node-user-settings\",\n  version: \"1.0.0\",\n  author: \"noahweasley\"\n};\n\nconst isPersisted = settings.serializeSync(mockData, optionalFileName);\nconsole.log(`Is data changed ? ${isPersisted ? `YES` : `NO`}`);\n```\n\n### `deserializeSync(optionalFileName)`\n\nSynchronously retrieves all the data in preference\n\n### Parameter\n\n---\n\n### optionalFileName\n\n#### Type: `String`\n\nAn optional filename used to persist the settings. This can be left _null_\n\n#### Returns\n\n_A String_. The persisted object as it exists in preference\n\n**Example**\n\n```javascript\nconst data = settings.deserializeSync(optionalFileName);\nconsole.log(data);\n```\n\n## License 📒\n\nNode User Settings is licensed to everyone under the MIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoahweasley%2Fnode-user-settings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnoahweasley%2Fnode-user-settings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnoahweasley%2Fnode-user-settings/lists"}