# xray

> Scan/search javascript objects and their properties

Latest version **0.5.1** (published 2016-11-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install xray
pnpm add xray
yarn add xray
bun add xray
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.1 |
| Published | 2016-11-09 |
| First published | 2013-04-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Janek L.B. |
| Maintainers | janek |
| Keywords | scan, search |

## Links

- npm: https://www.npmjs.com/package/xray
- Repository: https://github.com/janeklb/xray.js
- Homepage: https://github.com/janeklb/xray.js#readme
- Issues: https://github.com/janeklb/xray.js/issues
- npm.io page: https://npm.io/package/xray

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 0.5.1 (latest) — 2016-11-09
- 0.5.0 — 2014-05-26
- 0.4.0 — 2013-07-20
- 0.3.0 — 2013-04-21

## README

# xray.js

Recursively scan JavaScript objects' properties. Useful for testing to see whether an object contains something of interest. If you're using Google Chrome, consider loading this via [JSKit](https://chrome.google.com/webstore/detail/jskit/aopfdhabfojdkgcmibiegfhpfkcokmdg).

[![Travis Build Status](https://api.travis-ci.org/janeklb/xray.js.png?branch=master)](https://travis-ci.org/janeklb/xray.js)

### Usage:

`xray(object, scanner)` returns an array of JSONPaths to (nested) object values that are matched by the scanner

```javascript
someObj = {
    propA: 1,
    propB: "find me",
    propC: {
        propA: "find me",
        propB: [
            "can you", "find me", "too"
        ],
        propC: {
            tooDeep: {
                propA: "hello... can you find me"
            }
        },
        "propD-find me": "OK"
    }
};

// Scan the object with a string:
paths = xray(someObj, "find me", {
    scan_keys:        true, // will also attempt to match the key names
    max_depth:        2     // recursion depth
});

// paths === ["$.propB", "$.propC.propA", "$.propC['propD-find me']"]

// Or, with a RegExp object:
paths = xray(someObj, /find ME/i, {
    // ...
})

// Or, with a custom function that indicates a match by returning a truthy value:
paths = xray(someObj, function(value, properties) {
    // properties has:
    //  isKey: boolean
    //  path: path to current value
    return value === "find me";
}, {
    // ...
});

```

### Todo:

- handle DOM Node scanning better

### Changes:

0.5
- node module now directly exports a function (ie. `var xray = require('xray')` vs. `var xray = require('xray').xray`)
- JSONPath output
- added `properties` argument to custom scanner callback

---
_Source: https://npm.io/package/xray · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
