# script-tool

> script tool

Latest version **1.0.2** (published 2021-11-09) · ISC license · 0 weekly downloads

## Install

```sh
npm install script-tool
pnpm add script-tool
yarn add script-tool
bun add script-tool
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2021-11-09 |
| First published | 2021-11-05 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 12.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | fwg |
| Maintainers | adf0001 |
| Keywords | script, tool |

## Links

- npm: https://www.npmjs.com/package/script-tool
- Repository: https://github.com/adf0001/script-tool
- Homepage: https://github.com/adf0001/script-tool#readme
- Issues: https://github.com/adf0001/script-tool/issues
- npm.io page: https://npm.io/package/script-tool

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2021-11-09
- 1.0.1 — 2021-11-05
- 1.0.0 — 2021-11-05

## README

# script-tool
script tool

# Install
```
npm install script-tool
```

# Usage & Api
```javascript

var st = require("script-tool");

//.getPropertyDescriptor(obj, prop)		//search property descriptor of an object, or of its prototype.
var b = { a: 11 };
var c = Object.create(b);

assert(!Object.getOwnPropertyDescriptor(c, "a"));
assert(!!st.getPropertyDescriptor(c, "a"));

//.enclosePropertyDescriptor(obj, prop, newSetter, newGetter, options)		//enclose property descriptor
var v1 = 0, v2 = 0, v3 = 0;

var b = { get a() { return v1; }, set a(v) { v1 = v; } };
b.a = 1;
assert(v1 === 1 && b.a === 1 && v2 === 0 && v3 === 0);

//new getter is not used
st.enclosePropertyDescriptor(b, "a", function (v) { v2 = v; }, function () { return v3; });
b.a = 2;
assert(v1 === 2 && b.a === 2 && v2 === 2 && v3 === 0);

//old getter is replaced
st.enclosePropertyDescriptor(b, "a", function (v) { v2 = v; }, function () { return v3; }, true);
b.a = 3;
assert(v1 === 3 && b.a === 0 && v2 === 3 && v3 === 0);

//.mapValue(mapper, value)		//try to transfer value by value mapper; if unfound, return original value.
var vm = { a: 11, b: 22 };
assert(st.mapValue(vm, "a") === 11 && st.mapValue(vm, "c") === "c");

var vm = function (v) { if (v == "a") return 11; return 33; }
assert(st.mapValue(vm, "a") === 11 && st.mapValue(vm, "c") === 33);

//.findWithFilter(filter, v /* , v2, ... */)		//find the value that the `filter` will return true; if unfound, return `undefined`

var filter = null;		//default filter exclude null, include only !!v, 0, "" and false.

assert(st.findWithFilter(filter, null, "a", "b") === "a");
assert(st.findWithFilter(filter, null, undefined, 0, "b") === 0);

filter = function (v) { return v == "b" || v === null; };	//only user-defined-value
assert(st.findWithFilter(filter, 0, "a", null, "b") === null);
assert(st.findWithFilter(filter, 0, "a", "b", null) === "b");

assert(typeof st.findWithFilter(filter, 0, "", "a") === "undefined");		//unfound

```

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