Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/derhuerst/node-spotlight
Search macOS using Spotlight.
https://github.com/derhuerst/node-spotlight
macos osx spotlight
Last synced: 5 days ago
JSON representation
Search macOS using Spotlight.
- Host: GitHub
- URL: https://github.com/derhuerst/node-spotlight
- Owner: derhuerst
- License: isc
- Created: 2016-12-22T19:49:00.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2022-11-23T23:59:14.000Z (almost 2 years ago)
- Last Synced: 2024-10-03T23:54:44.109Z (about 1 month ago)
- Topics: macos, osx, spotlight
- Language: JavaScript
- Homepage:
- Size: 44.9 KB
- Stars: 18
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license.md
Awesome Lists containing this project
README
# node-spotlight
**Search macOS using Spotlight.**
[![npm version](https://img.shields.io/npm/v/node-spotlight.svg)](https://www.npmjs.com/package/node-spotlight)
![ISC-licensed](https://img.shields.io/github/license/derhuerst/node-spotlight.svg)
![minimum Node.js version](https://img.shields.io/node/v/node-spotlight.svg)
[![support me via GitHub Sponsors](https://img.shields.io/badge/support%20me-donate-fa7664.svg)](https://github.com/sponsors/derhuerst)
[![chat with me on Twitter](https://img.shields.io/badge/chat%20with%20me-on%20Twitter-1da1f2.svg)](https://twitter.com/derhuerst)## Installing
```shell
npm install node-spotlight
```## Usage
```js
spotlight(query, directory, attributes)
``````js
const spotlight = require('node-spotlight')const results = spotlight('bvg-wlan', null, [
'kMDItemAuthors',
'kMDItemContentType',
'kMDItemFSInvisible',
'kMDItemKind',
'kMDItemNumberOfPages',
'kMDItemTitle',
'kMDItemUseCount',
'kMDItemVersion',
])
for await (const result of results) {
console.log('result', result)
}
``````js
{
path: '/Users/j/Downloads/bvg/bvg-wlan.pdf',
kMDItemAuthors: ['BVG VBA-FGI Kartographie'],
kMDItemContentType: 'com.adobe.pdf',
kMDItemFSInvisible: false,
kMDItemKind: 'Portable Document Format (PDF)',
kMDItemNumberOfPages: 1,
kMDItemTitle: 'S+U-Bahn_2901_2016_18-10_WLAN',
kMDItemUseCount: 15,
kMDItemVersion: '1.6'
}
// …
```## API
```js
spotlight(query, dir = null, filters = [])
```- `query` must be a string.
- `dir` is an optional string.
- `filters` is an optional array if attributes that should be filtered by.Returns an [async iterator/iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols) of search results.
## Contributing
If you **have a question**, **found a bug** or want to **propose a feature**, have a look at [the issues page](https://github.com/derhuerst/node-spotlight/issues).