Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove unused dependencies #226

Merged
merged 3 commits into from
Oct 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,12 @@
"@google-cloud/promisify": "^0.3.0",
"arrify": "^1.0.1",
"concat-stream": "^1.6.2",
"create-error-class": "^3.0.2",
"extend": "^3.0.1",
"google-auth-library": "^2.0.0",
"google-gax": "^0.20.0",
"google-proto-files": "^0.17.0",
"is": "^3.2.1",
"lodash.flatten": "^4.4.0",
"lodash.merge": "^4.6.1",
"prop-assign": "^1.0.0",
"split-array-stream": "^2.0.0",
"stream-events": "^1.0.4",
"through2": "^2.0.3"
Expand All @@ -84,7 +81,6 @@
"@google-cloud/nodejs-repo-tools": "^2.3.0",
"async": "^2.6.1",
"codecov": "^3.0.2",
"deep-strict-equal": "^0.2.0",
"eslint": "^5.0.0",
"eslint-config-prettier": "^3.0.0",
"eslint-plugin-node": "^8.0.0",
Expand Down
19 changes: 10 additions & 9 deletions src/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,21 @@
'use strict';

const arrify = require('arrify');
const createErrorClass = require('create-error-class');
const extend = require('extend');
const is = require('is');

const entity = module.exports;

const InvalidKeyError = createErrorClass('InvalidKey', function(opts) {
const errorMessages = {
MISSING_KIND: 'A key should contain at least a kind.',
MISSING_ANCESTOR_ID: 'Ancestor keys require an id or name.',
};

this.message = errorMessages[opts.code];
});
class InvalidKeyError extends Error {
constructor(opts) {
const errorMessages = {
MISSING_KIND: 'A key should contain at least a kind.',
MISSING_ANCESTOR_ID: 'Ancestor keys require an id or name.',
};
super(errorMessages[opts.code]);
this.name = 'InvalidKey';
}
}

/**
* A symbol to access the Key object from an entity object.
Expand Down
21 changes: 16 additions & 5 deletions src/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ const {promisifyAll} = require('@google-cloud/promisify');
const concat = require('concat-stream');
const extend = require('extend');
const is = require('is');
const propAssign = require('prop-assign');
const {split} = require('split-array-stream');
const streamEvents = require('stream-events');
const through = require('through2');
Expand Down Expand Up @@ -477,7 +476,10 @@ class DatastoreRequest {
insert(entities, callback) {
entities = arrify(entities)
.map(DatastoreRequest.prepareEntityObject_)
.map(propAssign('method', 'insert'));
.map(x => {
x.method = 'insert';
return x;
});

this.save(entities, callback);
}
Expand Down Expand Up @@ -967,7 +969,10 @@ class DatastoreRequest {
let values = value.arrayValue && value.arrayValue.values;

if (values) {
values = values.map(propAssign('excludeFromIndexes', excluded));
values = values.map(x => {
x.excludeFromIndexes = excluded;
return x;
});
} else {
value.excludeFromIndexes = data.excludeFromIndexes;
}
Expand Down Expand Up @@ -1045,7 +1050,10 @@ class DatastoreRequest {
update(entities, callback) {
entities = arrify(entities)
.map(DatastoreRequest.prepareEntityObject_)
.map(propAssign('method', 'update'));
.map(x => {
x.method = 'update';
return x;
});

this.save(entities, callback);
}
Expand All @@ -1067,7 +1075,10 @@ class DatastoreRequest {
upsert(entities, callback) {
entities = arrify(entities)
.map(DatastoreRequest.prepareEntityObject_)
.map(propAssign('method', 'upsert'));
.map(x => {
x.method = 'upsert';
return x;
});

this.save(entities, callback);
}
Expand Down
6 changes: 0 additions & 6 deletions test/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@
'use strict';

const assert = require('assert');
const deepStrictEqual = require('deep-strict-equal');
assert.deepStrictEqual =
assert.deepStrictEqual ||
function() {
return assert(deepStrictEqual.apply(this, arguments));
};
const extend = require('extend');

const Datastore = require('../');
Expand Down