Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

array-sync

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-sync - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

test-coverage.sh

4

CHANGELOG.md

@@ -6,2 +6,6 @@

## [2.0.1] - 2018-06-28
- You can now supply `keyOnly: false` in conjunction with the `key` option to have the entire object returned, rather than just the key.
## [2.0.0] - 2016-03-29

@@ -8,0 +12,0 @@

20

CONTRIBUTING.md
# Contributing to array-sync
array-sync comes complete with an isolated development environment. You aren't required to use it, if you already have what you get with the development environment then you're already good to go. All you need is:
To develop on array-sync, all you need is Git, Node.js and NPM.
- [Vagrant][vagrant]
- Virtualization software, either: [VMware Workstation][vmwareworkstation], [VMware Fusion][vmwarefusion] or [Virtual Box][virtualbox]
- [Git][git]
Once you've created the virtual machine you'll have an environment complete with:
- Node.js
- NPM
There are files for editors that should keep the file formatting consistent with what already exists in this repository.

@@ -23,5 +14,5 @@

1. Clone your forked repository `git clone https://github.com/smebberson/array-sync.git ./array-sync`.
1. Start the virtual machine with `vagrant up` (this might take 10 minutes or so).
1. Execute `npm install`.
With that, you'll have a virtual machine up and running.
With that, you'll have everything you need to get started.

@@ -40,9 +31,4 @@ ## Development

[vagrant]: https://www.vagrantup.com/
[vmwareworkstation]: https://www.vmware.com/au/products/workstation/
[vmwarefusion]: https://www.vmware.com/au/products/fusion/
[virtualbox]: https://www.virtualbox.org/
[git]: https://git-scm.com/
[mocha]: https://mochajs.org/
[chai]: http://chaijs.com/
[pullrequests]: http://help.github.com/pull-requests/

@@ -197,2 +197,6 @@

if (opts.key && typeof opts.keyOnly === 'undefined') {
opts.keyOnly = true;
}
// Return a promise (which will execute the callback if provided).

@@ -223,3 +227,3 @@ return new Promise(function (resolve, reject) {

// If we have a `key`, transform the results to contain only the key Object.
if (opts.key) {
if (opts.key && opts.keyOnly) {
r.remove = mapToKey(r.remove, opts.key);

@@ -226,0 +230,0 @@ r.unchanged = mapToKey(r.unchanged, opts.key);

{
"name": "array-sync",
"version": "2.0.0",
"version": "2.0.1",
"description": "Data synchronisation module for Node.js",

@@ -11,4 +11,4 @@ "main": "index.js",

"test": "./node_modules/.bin/mocha",
"coverage": "./vagrant/scripts/test-coverage",
"travis": "./vagrant/scripts/test-travis"
"coverage": "./test-coverage.sh",
"travis": "./test-travis.sh"
},

@@ -15,0 +15,0 @@ "repository": {

@@ -115,2 +115,6 @@ # array-sync

##### keyOnly
Defaults to `true`, and is only relevant when a `key` is provided. By default the `remove` and `unchanged` results only provide the id (the field specificed by the `key` option), not the entire object. Setting `keyOnly` to `false` will ensure the entire object is returned rather than just the id.
##### comparator

@@ -155,3 +159,3 @@

Contributors are welcomed. array-sync comes complete with an isolated development environment. You can [read more about contributing to array-sync here](CONTRIBUTING.md).
Contributors are welcomed. You can [read more about contributing to array-sync here](CONTRIBUTING.md).

@@ -158,0 +162,0 @@ ## License

@@ -404,2 +404,50 @@

it('and return complete objects', function (done) {
arraySync([
{ type: 'fruit', _id: 'one', label: 'Apple' },
{ type: 'fruit', _id: 'two', label: 'Orange' },
{ type: 'fruit', _id: 'three', label: 'Grape' },
{ type: 'fruit', _id: 'four', label: 'Cucumber' },
{ type: 'fruit', _id: 'five', label: 'Plum' }
], [
{ type: 'fruit', _id: 'one', label: 'Apple' },
{ type: 'fruit', _id: 'two', label: 'Orange' },
{ type: 'fruit', _id: 'three', label: 'Grape' },
{ type: 'vegetable', _id: 'four', label: 'Cucumber' },
{ type: 'vegetable', _id: 'six', label: 'Pumpkin' }
], {
key: '_id',
keyOnly: false,
}, function (err, result) {
expect(err).to.not.exist;
expect(result).to.exist;
expect(result).to.have.property('unchanged');
expect(result.unchanged).to.have.length(3);
expect(result.unchanged[0]).to.eql({ type: 'fruit', _id: 'one', label: 'Apple' });
expect(result.unchanged[1]).to.eql({ type: 'fruit', _id: 'two', label: 'Orange' });
expect(result.unchanged[2]).to.eql({ type: 'fruit', _id: 'three', label: 'Grape' });
expect(result).to.have.property('create');
expect(result.create).to.have.length(1);
expect(result.create[0]).to.eql({ type: 'vegetable', _id: 'six', label: 'Pumpkin' });
expect(result).to.have.property('remove');
expect(result.remove).to.have.length(1);
expect(result.remove[0]).to.eql({ type: 'fruit', _id: 'five', label: 'Plum' });
expect(result).to.have.property('changed');
expect(result.changed).to.have.length(1);
expect(result.changed[0]).to.eql({ type: 'vegetable', _id: 'four', label: 'Cucumber' });
return done(err);
});
});
});

@@ -406,0 +454,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc