extract-vars

Hello!

ISC 14 个版本
安装
npm install extract-vars
yarn add extract-vars
pnpm add extract-vars
bun add extract-vars
README

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 2016-10-30
1.1.2 2016-10-30
1.1.1 2016-10-30
1.1.0 2016-10-11
1.0.9 2016-10-10
1.0.8 2016-10-10
1.0.7 2016-10-08
1.0.6 2016-10-07
1.0.5 2016-09-30
1.0.4 2016-09-30
1.0.3 2016-09-30
1.0.2 2016-09-29
1.0.1 2016-09-29
1.0.0 2016-09-29