Repository: posva/vue-reactive-refs
Branch: master
Commit: 44c6a65c0340
Files: 22
Total size: 21.8 KB
Directory structure:
gitextract_srlkjowc/
├── .github/
│ ├── CODE_OF_CONDUCT.md
│ ├── CONTRIBUTING.md
│ ├── ISSUE_TEMPLATE.md
│ ├── PULL_REQUEST_TEMPLATE.md
│ ├── funding.yml
│ └── settings.yml
├── .gitignore
├── LICENSE
├── README.md
├── __tests__/
│ ├── tsconfig.json
│ ├── with-proxy-array.spec.ts
│ ├── with-proxy.spec.ts
│ ├── without-proxy-array.spec.ts
│ └── without-proxy.spec.ts
├── circle.yml
├── jest.config.js
├── package.json
├── rollup.config.js
├── src/
│ ├── index.ts
│ ├── no-proxy.ts
│ └── proxy.ts
└── tsconfig.json
================================================
FILE CONTENTS
================================================
================================================
FILE: .github/CODE_OF_CONDUCT.md
================================================
# Contributor Code of Conduct
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
================================================
FILE: .github/CONTRIBUTING.md
================================================
# Contributing
Contributions are welcome and will be fully credited!
We accept contributions via Pull Requests on [Github](https://github.com/{{ githubAccount }}/{{ name }}).
## Pull Requests
Here are some guidelines to make the process smoother:
- **Add a test** - New features and bugfixes need tests. If you find it difficult to test, please tell us in the pull request and we will try to help you!
- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
- **Run `npm test` locally** - This will allow you to go faster
- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
- **Send coherent history** - Make sure your commits message means something
- **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option.
## Creating issues
### Bug reports
Always try to provide as much information as possible. If you are reporting a bug, try to provide a repro on jsfiddle.net (or anything else) or a stacktrace at the very least. This will help us check the problem quicker.
### Feature requests
Lay out the reasoning behind it and propose an API for it. Ideally, you should have a practical example to prove the utility of the feature you're requesting.
================================================
FILE: .github/ISSUE_TEMPLATE.md
================================================
================================================
FILE: .github/PULL_REQUEST_TEMPLATE.md
================================================
**What kind of change does this PR introduce?** (check at least one)
- [ ] Bugfix
- [ ] Feature
- [ ] Code style update
- [ ] Refactor
- [ ] Build-related changes
- [ ] Other, please describe:
**Does this PR introduce a breaking change?** (check one)
- [ ] Yes
- [ ] No
If yes, please describe the impact and migration path for existing applications:
**The PR fulfills these requirements:**
- [ ] When resolving a specific issue, it's referenced in the PR's title (e.g. `fix #xxx[,#xxx]`, where "xxx" is the issue number)
- [ ] All tests are passing
- [ ] New/updated tests are included
If adding a **new feature**, the PR's description includes:
- [ ] A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)
**Other information:**
================================================
FILE: .github/funding.yml
================================================
github: posva
custom: https://www.paypal.me/posva
================================================
FILE: .github/settings.yml
================================================
labels:
- name: bug
color: ee0701
- name: contribution welcome
color: 0e8a16
- name: discussion
color: 4935ad
- name: docs
color: 8be281
- name: enhancement
color: a2eeef
- name: good first issue
color: 7057ff
- name: help wanted
color: 008672
- name: question
color: d876e3
- name: wontfix
color: ffffff
- name: WIP
color: ffffff
- name: need repro
color: c9581c
- name: feature request
color: fbca04
================================================
FILE: .gitignore
================================================
node_modules
coverage
npm-debug.log
yarn-error.log
.nyc_output
coverage.lcov
dist
package-lock.json
.DS_Store
.rpt2_cache
================================================
FILE: LICENSE
================================================
The MIT License (MIT)
Copyright (c) 2019 Eduardo San Martin Morote
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
# vue-reactive-refs [](https://circleci.com/gh/posva/vue-reactive-refs) [](https://www.npmjs.com/package/vue-reactive-refs) [](https://codecov.io/github/posva/vue-reactive-refs) [](https://github.com/posva/thanks)
> Make \$refs reactive so they can be used in computed properties and watchers
**Vue 2 only** as you don't need this in Vue 3
Extremely Light < 0.2kb 🗜
## Installation
```sh
npm install vue-reactive-refs
```
## Usage
This library exposes two different plugins: `ReactiveRefs` and
`DynamicReactiveRefs` and you should **only use one of them**
### `ReactiveRefs`
Supports all browsers but requires you to manually declare `refs` in component
options.
```js
import { ReactiveRefs } from 'vue-reactive-refs'
import Vue from 'vue'
Vue.use(ReactiveRefs)
```
MyComponent.vue
```vue
```
### `DynamicReactiveRefs`
Supports modern browsers (not IE) [that support
`Proxy`](https://caniuse.com/#search=proxy) and works out of the box:
```js
import { DynamicReactiveRefs } from 'vue-reactive-refs'
import Vue from 'vue'
Vue.use(DynamicReactiveRefs)
```
MyComponent.vue
```vue
```
## Related
- Vue.js issue: https://github.com/vuejs/vue/issues/3842
## License
[MIT](http://opensource.org/licenses/MIT)
================================================
FILE: __tests__/tsconfig.json
================================================
{
"extends": "../tsconfig.json",
"include": ["../src", "."]
}
================================================
FILE: __tests__/with-proxy-array.spec.ts
================================================
import { mount, createLocalVue } from '@vue/test-utils'
import { DynamicReactiveRefs } from '../src'
const localVue = createLocalVue()
localVue.use(DynamicReactiveRefs)
describe('Reactive Refs with Proxy', () => {
// for some reason this fails when run along other tests but works when run alone
it('it works with arrays', async () => {
const spy = jest.fn()
const wrapper = mount(
{
template: `