1.1.3 • Published 10 years ago

extract-vars v1.1.3

Weekly downloads
2
License
ISC
Repository
github
Last release
10 years ago

Build Status

Extract Watchables

extract-vars is a unique library that helps to extract variables from a javascript expression that could be possibly watched. In spite of its light weight extract-vars is a pretty powerful library. You can combine it with AsyncWatch and achieve a very performant watcher.

THe library is written to support 2-way binding framework development.

It is written in beautiful typescript, so you get typings along once installed.

Features

  • Extracts all watchable variables from a string exression
  • Uses a solid test set
  • Does not use RegEx at all (hence costs nothing)
  • Typings for typescript included
  • Universal dist.js (works on both frontend and server)

Use cases

Variable "dig" is exposed to window.

Extracts variables that should be watched. (imagine ng-class case)

dig(`{"active" : user.name === 'hello', disabled : !user.age > 18 && user.sex === 1}`)
// ["user.name", "user.age", "user.sex"]

Variable assignment, declaration are ignored as for one cannot watch them.

dig(`user.getFullName(user.name, "hello") user.age; var a = "111";e`) 
// ["user.name", "user.age"]

Submit an issue if you find a bug.

Star it you like it.

1.1.3

10 years ago

1.1.2

10 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.9

10 years ago

1.0.8

10 years ago

1.0.7

10 years ago

1.0.6

10 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago