repository-provider
Advanced tools
Comparing version 7.1.0 to 7.2.0
@@ -14,12 +14,23 @@ 'use strict'; | ||
* @see Object.definedProperties() | ||
* @param {Object} properties where the properties will be stored | ||
* @param {Object} object target object | ||
* @param {Object} properties object properties | ||
* @param {Object} options | ||
* @param {Object} defaultOptions | ||
*/ | ||
function propertiesFromOptions(properties, options, defaultOptions) { | ||
function definePropertiesFromOptions(object, properties, options) { | ||
const defaultOptions = object.constructor.defaultOptions; | ||
const after = {}; | ||
Object.keys(defaultOptions).forEach(name => { | ||
properties[name] = { | ||
value: (options !== undefined && options[name]) || defaultOptions[name] | ||
}; | ||
const value = (options !== undefined && options[name]) || defaultOptions[name]; | ||
if(properties[name] === undefined) { | ||
properties[name] = { value }; | ||
} | ||
else { | ||
after[name]=value; | ||
} | ||
}); | ||
Object.defineProperties(object, properties); | ||
Object.assign(object,after); | ||
} | ||
@@ -79,15 +90,11 @@ | ||
constructor(repository, name = "master", options) { | ||
const properties = { | ||
name: { value: name }, | ||
repository: { value: repository } | ||
}; | ||
propertiesFromOptions( | ||
properties, | ||
options, | ||
this.constructor.defaultOptions | ||
definePropertiesFromOptions( | ||
this, | ||
{ | ||
name: { value: name }, | ||
repository: { value: repository } | ||
}, | ||
options | ||
); | ||
Object.defineProperties(this, properties); | ||
repository.addBranch(this); | ||
@@ -252,5 +259,9 @@ } | ||
*/ | ||
async *entries(matchingPatterns) { | ||
} | ||
async *entries(matchingPatterns) {} | ||
/** | ||
* get exactly one matchin enty by name | ||
* @param {string} name | ||
* @return {Promise<Entry>} | ||
*/ | ||
async entry(name) { | ||
@@ -333,16 +344,12 @@ return (await this.entries(name).next()).value; | ||
const properties = { | ||
name: { value: name }, | ||
owner: { value: owner }, | ||
_branches: { value: new Map() }, | ||
_pullRequests: { value: new Map() } | ||
}; | ||
propertiesFromOptions( | ||
properties, | ||
options, | ||
this.constructor.defaultOptions | ||
definePropertiesFromOptions( | ||
this, | ||
{ | ||
name: { value: name }, | ||
owner: { value: owner }, | ||
_branches: { value: new Map() }, | ||
_pullRequests: { value: new Map() } | ||
}, | ||
options | ||
); | ||
Object.defineProperties(this, properties); | ||
} | ||
@@ -452,3 +459,7 @@ | ||
if (branch === undefined) { | ||
branch = await this._createBranch(name, source === undefined ? await this.defaultBranch : source, options); | ||
branch = await this._createBranch( | ||
name, | ||
source === undefined ? await this.defaultBranch : source, | ||
options | ||
); | ||
this._branches.set(branch.name, branch); | ||
@@ -860,32 +871,28 @@ } | ||
constructor(source, destination, name, options) { | ||
let merged, state; | ||
const properties = { | ||
name: { value: name }, | ||
source: { value: source }, | ||
destination: { value: destination } | ||
}; | ||
propertiesFromOptions(properties, options, this.constructor.defaultOptions); | ||
let merged = properties.merged.value; | ||
properties.merged = { | ||
set(value) { | ||
merged = value; | ||
destination: { value: destination }, | ||
merged: { | ||
set(value) { | ||
merged = value; | ||
}, | ||
get() { | ||
return merged; | ||
} | ||
}, | ||
get() { | ||
return merged; | ||
state: { | ||
set(value) { | ||
state = value; | ||
}, | ||
get() { | ||
return state; | ||
} | ||
} | ||
}; | ||
let state = properties.state.value; | ||
properties.state = { | ||
set(value) { | ||
state = value; | ||
}, | ||
get() { | ||
return state; | ||
} | ||
}; | ||
definePropertiesFromOptions(this, properties, options); | ||
Object.defineProperties(this, properties); | ||
destination.addPullRequest(this); | ||
@@ -1100,10 +1107,10 @@ } | ||
const properties = { | ||
name: { value: name }, | ||
provider: { value: provider } | ||
}; | ||
propertiesFromOptions(properties, options, this.constructor.defaultOptions); | ||
Object.defineProperties(this, properties); | ||
definePropertiesFromOptions( | ||
this, | ||
{ | ||
name: { value: name }, | ||
provider: { value: provider } | ||
}, | ||
options | ||
); | ||
} | ||
@@ -1181,13 +1188,13 @@ | ||
const properties = { | ||
config: { | ||
// TODO ret rid of config | ||
value: this.constructor.options(options) | ||
definePropertiesFromOptions( | ||
this, | ||
{ | ||
config: { | ||
// TODO ret rid of config | ||
value: this.constructor.options(options) | ||
}, | ||
repositoryGroups: { value: new Map() } | ||
}, | ||
repositoryGroups: { value: new Map() } | ||
}; | ||
propertiesFromOptions(properties, options, this.constructor.defaultOptions); | ||
Object.defineProperties(this, properties); | ||
options | ||
); | ||
} | ||
@@ -1194,0 +1201,0 @@ |
{ | ||
"name": "repository-provider", | ||
"version": "7.1.0", | ||
"version": "7.2.0", | ||
"publishConfig": { | ||
@@ -38,3 +38,3 @@ "access": "public" | ||
"markdown-doctest": "^0.9.1", | ||
"rollup": "^0.67.1", | ||
"rollup": "^0.67.3", | ||
"rollup-plugin-cleanup": "^3.0.0", | ||
@@ -41,0 +41,0 @@ "rollup-plugin-commonjs": "^9.2.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2320
70728