{"id":14978543,"url":"https://github.com/codebytere/node-mac-userdefaults","last_synced_at":"2025-10-28T11:30:20.510Z","repository":{"id":43093960,"uuid":"271065650","full_name":"codebytere/node-mac-userdefaults","owner":"codebytere","description":"A native Node.js module that provides an interface to the user’s defaults database on macOS.","archived":false,"fork":false,"pushed_at":"2024-02-21T11:13:07.000Z","size":287,"stargazers_count":15,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-04-14T07:25:54.697Z","etag":null,"topics":["electronjs","macos","node-addon","nodejs","nsuserdefaults","userdefaults"],"latest_commit_sha":null,"homepage":"","language":"Objective-C++","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/codebytere.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2020-06-09T17:21:33.000Z","updated_at":"2024-03-31T07:42:58.000Z","dependencies_parsed_at":"2024-02-21T12:28:09.987Z","dependency_job_id":"4cf30d00-977f-44dd-b5ea-7ca4ac7a21a7","html_url":"https://github.com/codebytere/node-mac-userdefaults","commit_stats":{"total_commits":43,"total_committers":2,"mean_commits":21.5,"dds":0.2558139534883721,"last_synced_commit":"59e2c89acc8a2e5ec8e345e3c454de8836937144"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codebytere%2Fnode-mac-userdefaults","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codebytere%2Fnode-mac-userdefaults/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codebytere%2Fnode-mac-userdefaults/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codebytere%2Fnode-mac-userdefaults/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codebytere","download_url":"https://codeload.github.com/codebytere/node-mac-userdefaults/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238638154,"owners_count":19505546,"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":["electronjs","macos","node-addon","nodejs","nsuserdefaults","userdefaults"],"created_at":"2024-09-24T13:57:52.776Z","updated_at":"2025-10-28T11:30:20.071Z","avatar_url":"https://github.com/codebytere.png","language":"Objective-C++","readme":"[![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://lbesson.mit-license.org/)\n [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) [![Lint Status](https://github.com/codebytere/node-mac-userdefaults/workflows/Lint/badge.svg)](https://github.com/codebytere/node-mac-userdefaults/actions) [![Test Status](https://github.com/codebytere/node-mac-userdefaults/workflows/Test/badge.svg)](https://github.com/codebytere/node-mac-userdefaults/actions)\n\n# node-mac-userdefaults\n\n```js\n$ npm i node-mac-userdefaults\n```\n\nThis native Node.js module provides an interface to the user’s defaults database on macOS.\n\n## API\n\n### `defaults.getAllDefaults([domain])`\n\n* `domain` String (optional) - The domain identifier for an `NSUserDefaults` suite.\n\nReturns `Record\u003cstring, any\u003e` - An object containing all currently set defaults and their values for the current user.\n\nExample:\n```js\nconst { getAllDefaults } = require('node-mac-userdefaults')\n\nconst allDefaults = getAllDefaults()\n\nconsole.log(allDefaults)\n/*\n{\n  'com.apple.springing.enabled': 1,\n  'Brother MFC-J985DW': '1',\n  'com.apple.trackpad.enableSecondaryClick': 1,\n  'HP DeskJet 2600 series': '1',\n  'com.apple.trackpad.rotateGesture': 1,\n  NSNavPanelFileListModeForOpenMode2: 3,\n  Country: 'US',\n  'com.apple.preferences.timezone.selected_city': {\n    AppleMapID: '\\x1Dq\\x13\\x13u\\x1C\\x19'\n  },\n  'Brother MFC-L9570CDW series': '1',\n  WebAutomaticSpellingCorrectionEnabled: 1,\n  'com.apple.trackpad.momentumScroll': 1,\n  AKLastIDMSEnvironment: 0,\n  'Hewlett Packard MFP M477fdn': '1',\n  NSAutomaticTextCompletionCollapsed: 0,\n  'com.apple.trackpad.fourFingerPinchSwipeGesture': 2,\n  AppleShowAllExtensions: 1,\n  'com.apple.trackpad.threeFingerTapGesture': 0,\n  NSQuitAlwaysKeepsWindows: 0,\n  'com.apple.trackpad.fourFingerVertSwipeGesture': 2,\n  NSLinguisticDataAssetsRequestTime: '2020-06-10 00:57:28 +0000',\n  NSAutomaticPeriodSubstitutionEnabled: 1,\n  'com.apple.springing.delay': 0,\n  'HP ENVY 5000 series': '1',\n  'com.apple.sound.beep.flash': 0,\n  AppleShowScrollBars: 'Automatic',\n  ...\n*/\n``` \n\n### `defaults.getUserDefault(type, key[, domain])`\n\n* `key` String - The `NSUserDefault` to fetch, e.g `AppleInterfaceStyle`.\n* `type` String - Can be one of `string`, `boolean`, `integer`, `float`, `double`,\n  `url`, `array` or `dictionary`.\n* `domain` String (optional) - The domain identifier for an `NSUserDefaults` suite.\n\nReturns `any` - The value of `key` in `NSUserDefaults` of type `type`.\n\nExample:\n```js\nconst { getUserDefault } = require('node-mac-userdefaults')\n\nconst interfaceStyle = getUserDefault('AppleInterfaceStyle', 'string')\n\nconsole.log(interfaceStyle) // 'Dark'\n```\n\n### `defaults.setUserDefault(type, key, value[, domain])`\n\n* `type` String - Can be `string`, `boolean`, `integer`, `float`, `double`, `url`, `array` or `dictionary`.\n* `key` String - The `NSUserDefault` to update, e.g `AppleInterfaceStyle`.\n* `value` any - The new value to set for `key`; must match type of `type`.\n* `domain` String (optional) - The domain identifier for an `NSUserDefaults` suite.\n\nSets the value of `key` in `NSUserDefaults`.\n\nExample:\n```js\nconst { setUserDefault } = require('node-mac-userdefaults')\n\nsetUserDefault('boolean', 'ApplePressAndHoldEnabled', true)\n```\n\nNote: `NSGlobalDomain` is an invalid domain name because it isn't writeable by apps.\n\n### `defaults.removeUserDefault(key[, domain])`\n\n* `key` String - The `NSUserDefault` to remove, e.g `AppleInterfaceStyle`.\n* `domain` String (optional) - The domain identifier for an `NSUserDefaults` suite.\n\nRemoves the `key` in `NSUserDefaults`.\n\nThis can be used to restore the default or global value of a `key` previously set with `setUserDefault`.\n\nExample:\n```js\nconst { removeUserDefault } = require('node-mac-userdefaults')\n\nremoveUserDefault('ApplePressAndHoldEnabled')\n```\n\nNote: `NSGlobalDomain` is an invalid domain name because it isn't writeable by apps.\n\n###  `defaults.isKeyManaged(key[, domain])`\n\n* `key` String - The `NSUserDefault` to check, e.g `AppleInterfaceStyle`.\n* `domain` String (optional) - The domain identifier for an `NSUserDefaults` suite.\n\nReturns a Boolean value indicating whether the specified key is managed by an administrator.\n\nExample:\n```js\nconst { isKeyManaged } = require('node-mac-userdefaults')\n\nconst managed = isKeyManaged('ApplePressAndHoldEnabled')\n\nconsole.log(managed) // false\n```\n\n###  `defaults.addDomain(name)`\n\n* `name` String - The name of the domain to insert into the user’s domain hierarchy.\n\nInserts the specified domain name into the user’s domain hierarchy.\n\nExample:\n```js\nconst { addDomain } = require('node-mac-userdefaults')\n\naddDomain('DomainForMyApp')\n```\n\n###  `defaults.removeDomain(name)`\n\n* `name` String - The name of the domain to remove from the user’s domain hierarchy.\n\nRemoved the specified domain name into the user’s domain hierarchy.\n\nExample:\n```js\nconst { removeDomain } = require('node-mac-userdefaults')\n\nremoveDomain('DomainForMyApp')\n```\n\nNote: Passing `NSGlobalDomain` is unsupported.\n\n## FAQ\n\n### What are domains?\n\nThe `NSUserDefaults` database consists of a hierarchy of domains. Whenever you read the value for a given key, `NSUserDefaults` traverses this hierarchy from top to bottom and returns the first value it finds. These domains can be either persistent (stored on disk) or volatile (only valid for the lifetime of the `NSUserDefaults` instance).\n\n| Domain Name | Description  | State |\n|---|---|---|\n| `NSArgumentDomain` | The domain consisting of defaults parsed from the application’s arguments | volatile |\n| `NSGlobalDomain` | The domain consisting of defaults meant to be seen by all applications | persistent |\n| `NSRegistrationDomain` | The domain consisting of a set of temporary defaults whose values can be set by the application to ensure that searches will always be successful | volatile |\n\nYou can also specify custom domains to store a set of preferences.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodebytere%2Fnode-mac-userdefaults","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodebytere%2Fnode-mac-userdefaults","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodebytere%2Fnode-mac-userdefaults/lists"}