Skip to content

Commit

Permalink
chore: renamed to vue-chemistry
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jan 6, 2021
1 parent 8ed14d6 commit d31acd7
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 18 deletions.
49 changes: 37 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
# @vueuse/reactified
# ⚗️ Vue Chemistry

**WIP**

Reactive utility wrappers powered by [`reactify`](https://vueuse.js.org/?path=/story/utilities--reactify) in [`VueUse`](https://github.com/antfu/vueuse)
The ~~science~~ that deals with the [properties](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects#objects_and_properties), [composition](https://v3.vuejs.org/guide/composition-api-introduction.html#why-composition-api), and structure of states, the transformations they undergo during [reactions](https://v3.vuejs.org/guide/reactivity.html#what-is-reactivity). A library providing reactive JavaScript utility wrappers which are powered by [`reactify`](https://vueuse.js.org/?path=/story/utilities--reactify) from [VueUse](https://github.com/antfu/vueuse).

## Install

```bash
npm i @vueuse/reactified
npm i vue-chemistry
```

## Usage

```js
import { sqrt, pow, sum, sin, round } from '@vueuse/reactified/math'
import { toString, toUpperCase } from '@vueuse/reactified/string'
import { parseInt, parseFloat } from '@vueuse/reactified/number'
import { stringify, parse } from '@vueuse/reactified/json'
import { isFalsy } from '@vueuse/reactified/boolean'
import { log } from '@vueuse/reactified/console'
import { sqrt, pow, sum, sin, round } from 'vue-chemistry/math'
import { toString, toLowerCase } from 'vue-chemistry/string'
import { parseInt, parseFloat } from 'vue-chemistry/number'
import { parse, stringify } from 'vue-chemistry/json'
import { isFalsy } from 'vue-chemistry/boolean'
import { log } from 'vue-chemistry/console'
```

## Example

```js
import { ref } from 'vue'
import { log } from '@vueuse/reactified/console'
import { sqrt, pow, sum } from '@vueuse/reactified/math'
import { stringify, parse } from '@vueuse/reactified/json'
import { get } from 'vue-chemistry'
import { dec } from 'vue-chemistry/number'
import { log } from 'vue-chemistry/console'
import { stringify, parse } from 'vue-chemistry/json'
import { rs, toUpperCase } from 'vue-chemistry/string'
import { sqrt, pow, sum, multiply } from 'vue-chemistry/math'

// Math _________
// c = √ a² + b²
Expand All @@ -51,4 +54,26 @@ log(str) // {"foo":"bar"}

obj.value.no = 42
log(str) // {"foo":"bar","no":42}

// String
// rs - Reactive String
const name = ref('oo')
const message = rs`Hello ${toUpperCase(name)}!`
log(message) // Hello FOO!
set(name, 'Anthony')
log(message) // Hello ANTHONY!

// String 2
//
const x = ref(9)
const y = ref(9)
const z = ref(7)
const equation = rs`${x} x ${y} + ${z} = ${sum(multiply(x, y),z)}`
log(equation) // 9 x 9 + 7 = 88
set(x, 98)
dec(z)
log(equation) // 98 x 9 + 6 = 888
set(x, 987)
dec(z)
log(equation) // 987 x 9 + 5 = 8888
```
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "@vueuse/reactified",
"version": "0.0.7",
"description": "Reactive utility wrappers for Vue",
"name": "vue-chemistry",
"version": "0.0.1",
"description": "Reactive JavaScript utilities",
"author": "Anthony Fu <[email protected]>",
"license": "MIT",
"sideEffects": false,
"types": "./index.d.ts",
"funding": "https://github.com/sponsors/antfu",
"exports": {
"./json": {
"import": "./esm/json/index.js",
Expand Down Expand Up @@ -33,12 +34,12 @@
}
},
"bugs": {
"url": "https://github.com/vueuse-reactified/issues"
"url": "https://github.com/vue-chemistry/issues"
},
"homepage": "https://github.com/vueuse-reactified#readme",
"homepage": "https://github.com/vue-chemistry#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/vueuse-reactified.git"
"url": "git+https://github.com/vue-chemistry.git"
},
"scripts": {
"build": "esno scripts/build.ts",
Expand Down
6 changes: 6 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { MaybeRef } from '@vueuse/shared'
import { Ref, unref } from 'vue-demi'

export function set<T>(a: Ref<T>, v: T) { a.value = v }

export function get<T>(a: MaybeRef<T>) { return unref(a) }
4 changes: 4 additions & 0 deletions src/number/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { reactify } from '@vueuse/shared'
import { Ref } from 'vue'

export * from './generated'

Expand All @@ -13,3 +14,6 @@ export const isNaN = reactify(global.isNaN)

/*@__PURE__*/
export const isFinite = reactify(global.isFinite)

export function inc(a: Ref<number>, v: number) { a.value += v }
export function dec(a: Ref<number>, v: number) { a.value -= v }

0 comments on commit d31acd7

Please sign in to comment.