# @st-lib/private

> Utility for creating private properties and methods.

Latest version **1.0.0** (published 2020-06-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install @st-lib/private
pnpm add @st-lib/private
yarn add @st-lib/private
bun add @st-lib/private
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2020-06-20 |
| First published | 2020-06-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | padreramnt |
| Maintainers | st-lib |
| Keywords | st-lib, private |

## Links

- npm: https://www.npmjs.com/package/@st-lib/private
- Repository: https://github.com/Padreramnt/st-lib--private
- Homepage: https://github.com/Padreramnt/st-lib--private#readme
- Issues: https://github.com/Padreramnt/st-lib--private/issues
- npm.io page: https://npm.io/package/@st-lib/private

## Recent versions

- 1.0.0 (latest) — 2020-06-20

## README

# Utility for creating private properties and methods.

```ts
import { createProperty, createMethod } from '@st-lib/private'

const [getProperty, setProperty] = createProperty<string>()
const [method, defineMethod] = createMethod<[string], string>()

class Class {
	constructor() {
		setProperty(this, 'init property value')
		defineMethod(this, (value) => value.toUpperCase())
	}

	publicMethod() {
		const value = getProperty(this) // thows ReferenceError if property not defined
		const preparedValue = method(this, value) // thows ReferenceError if method not defined
		return preparedValue
	}
}
```

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