0.8.0 • Published 7 months ago

@soulofmischief/proxy.js v0.8.0

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

Proxy.js

A collection of useful JavaScript Proxy utilities.

Installation

npm install @soulofmischief/proxy.js

Methods

after

after( model, callback = () => null, passValue = false )

Execute a callback after each property access or assignment.

Usage

import { after } from '@soulofmischief/proxy.js'

// Log each property access.
const proxy = after( obj, console.log, true )

proxy.val
// undefined

Parameters

model object

Object to proxy.

callback function

Callback to execute after each access.

passValue boolean

Pass the computed value to the callback.

before

before( model, callback = () => null, passValue = false )

Execute a callback before each property access or assignment.

Usage

import { before } from '@soulofmischief/proxy.js'

// Log each property access.
const proxy = before( obj, console.log, true )

proxy.val = 'test'
// 'test'

Parameters

model object

Object to proxy.

callback function

Callback to execute before each access.

passValue boolean

Pass the provided value to the callback.

log

log( model, { exclude: '', include: '', logger: console.log })

Log each property access or assignment.

Usage

import { log } from '@soulofmischief/proxy.js'

// Log each property access.
const proxy = log( obj )

proxy.val
// GET val
// undefined

Parameters

model object

Object to log.

options.include string|Array<string>

Access types to include.

options.exclude string|Array<string>

Access types to exclude.

options.logger function

Logging callback.

store

store[ key ] = val

JSON-serialized shallow store using localStorage.

Usage

import { store } from '@soulofmischief/proxy.js'

// Store a value.
store.test = { key: 'value' }

// Retrieve value.
console.log( store.test )
// { key: 'value' }
0.8.0

7 months ago

0.7.0

7 months ago

0.6.1

7 months ago

0.5.1

7 months ago

0.6.0

1 year ago

0.5.0

2 years ago

0.4.0

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.3.0

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago