Skip to content

Commit 3a15786

Browse files
committed
fix: appropriately name helper func, update deps, license
1 parent 01a5062 commit 3a15786

File tree

5 files changed

+1707
-1255
lines changed

5 files changed

+1707
-1255
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2020 Jason Franz <jfrazx> staringblind at gmail.com
3+
Copyright (c) 2021 Jason Franz <jfrazx> staringblind at gmail.com
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

package.json

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,24 @@
2828
"dependencies": {},
2929
"devDependencies": {
3030
"@semantic-release/commit-analyzer": "^8.0.1",
31-
"@semantic-release/release-notes-generator": "^9.0.1",
32-
"@types/jest": "^26.0.10",
33-
"@types/mongoose": "^5.7.36",
34-
"@typescript-eslint/parser": "^4.0.1",
35-
"codecov": "^3.7.2",
36-
"commitizen": "^4.2.1",
31+
"@semantic-release/release-notes-generator": "^9.0.2",
32+
"@types/jest": "^26.0.22",
33+
"@types/mongoose": "^5.10.4",
34+
"@typescript-eslint/parser": "^4.20.0",
35+
"codecov": "^3.8.1",
36+
"commitizen": "^4.2.3",
3737
"cz-conventional-changelog": "^3.3.0",
38-
"eslint": "^7.7.0",
39-
"husky": "^4.2.5",
40-
"jest": "^26.4.2",
41-
"mongodb-memory-server": "^6.6.6",
42-
"mongoose": "^5.10.2",
43-
"prettier": "^2.1.1",
38+
"eslint": "^7.23.0",
39+
"husky": "^6.0.0",
40+
"jest": "^26.6.3",
41+
"mongodb-memory-server": "^6.9.6",
42+
"mongoose": "^5.12.3",
43+
"prettier": "^2.2.1",
4444
"rimraf": "^3.0.2",
45-
"semantic-release": "^17.1.1",
45+
"semantic-release": "^17.4.2",
4646
"travis-deploy-once": "^5.0.11",
47-
"ts-jest": "^26.3.0",
48-
"typescript": "^4.0.2"
47+
"ts-jest": "^26.5.4",
48+
"typescript": "^4.2.3"
4949
},
5050
"config": {
5151
"commitizen": {
@@ -61,7 +61,5 @@
6161
"type": "git",
6262
"url": "https://github.com/jfrazx/mongoose-transient.git"
6363
},
64-
"peerDependencies": {
65-
"mongoose": ">= 4.4.5"
66-
}
64+
"peerDependencies": {}
6765
}

src/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,18 +87,18 @@ const setOptions = (path: string, trans: Transience): TransOpts => {
8787
};
8888

8989
const determineLinkTo = (trans: Transience): string[] =>
90-
isObject(trans) && trans.linkTo ? asArray(trans.linkTo) : [];
90+
isTransientOptions(trans) && trans.linkTo ? asArray(trans.linkTo) : [];
9191

9292
const determineArgs = (trans: Transience): any[] =>
93-
isObject(trans) && Array.isArray(trans.args) ? trans.args : [];
93+
isTransientOptions(trans) && Array.isArray(trans.args) ? trans.args : [];
9494

9595
const determineGetter = (trans: Transience): TransientCaller =>
96-
isObject(trans) && isFunction(trans.get) ? trans.get : defaultCaller;
96+
isTransientOptions(trans) && isFunction(trans.get) ? trans.get : defaultCaller;
9797

9898
const determineSetter = (trans: Transience): TransientCaller =>
9999
isFunction(trans)
100100
? trans
101-
: isObject(trans) && isFunction(trans.set)
101+
: isTransientOptions(trans) && isFunction(trans.set)
102102
? trans.set
103103
: defaultCaller;
104104

@@ -107,15 +107,15 @@ const defaultCaller: TransientCaller = (value: any) => value;
107107
const determinePropertyName = (path: string, trans: Transience): string =>
108108
isString(trans)
109109
? trans
110-
: isObject(trans) && isString(trans.as)
110+
: isTransientOptions(trans) && isString(trans.as)
111111
? trans.as
112112
: `_${path}`;
113113

114114
const asArray = <T>(value: T | T[]): T[] => (Array.isArray(value) ? value : [value]);
115115
const isFunction = (value: any): value is TransientCaller =>
116116
typeof value === 'function';
117117
const isString = (value: any): value is string => typeof value === 'string';
118-
const isObject = (value: any): value is TransientOptions =>
118+
const isTransientOptions = (value: any): value is TransientOptions =>
119119
value && !Array.isArray(value) && typeof value === 'object';
120120

121121
export default transient;

test/transient.spec.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@ import { MongoMemoryReplSet } from 'mongodb-memory-server';
33
import * as mongoose from 'mongoose';
44
import transient from '../src';
55

6-
const replSet = new MongoMemoryReplSet({
7-
replSet: { storageEngine: 'wiredTiger' },
8-
});
9-
106
describe('Mongoose Transient', () => {
7+
const replSet = new MongoMemoryReplSet({
8+
replSet: { storageEngine: 'wiredTiger' },
9+
});
10+
1111
beforeAll(async () => {
1212
await replSet.waitUntilRunning();
13+
1314
const uri = await replSet.getUri();
1415

1516
await mongoose.connect(uri, {
@@ -45,7 +46,7 @@ describe('Mongoose Transient', () => {
4546
expect(user.another).toBeDefined();
4647
});
4748

48-
it('should not have virtuals on pojo', () => {
49+
it('should not have virtual properties on plain objects', () => {
4950
const user = new User({
5051
name: 'Bart',
5152
password: 'eat!!!mysh0rts',
@@ -175,6 +176,7 @@ describe('Mongoose Transient', () => {
175176

176177
it('should not link to transient properties', () => {
177178
mongoose.plugin(transient);
179+
178180
const schema = new mongoose.Schema({
179181
testing: String,
180182
moar: {

0 commit comments

Comments
 (0)