repository-provider
Advanced tools
Comparing version 3.6.3 to 3.7.0
@@ -290,18 +290,15 @@ 'use strict'; | ||
class PullRequest { | ||
constructor(repository, name, options = {}) { | ||
Object.defineProperties( | ||
this, | ||
['title', 'state'].reduce( | ||
(a, key) => { | ||
if (options[key] !== undefined) { | ||
a[key] = { value: options[key] }; | ||
} | ||
return a; | ||
}, | ||
{ | ||
name: { value: name }, | ||
repository: { value: repository } | ||
} | ||
) | ||
); | ||
static get defaultOptions() { | ||
return { | ||
title: undefined, | ||
state: undefined | ||
}; | ||
} | ||
constructor(repository, name, options) { | ||
const properties = { | ||
name: { value: name }, | ||
repository: { value: repository } | ||
}; | ||
propertiesFromOptions(properties, options, this.constructor.defaultOptions); | ||
Object.defineProperties(this, properties); | ||
repository.addPullRequest(this); | ||
@@ -308,0 +305,0 @@ } |
{ | ||
"name": "repository-provider", | ||
"version": "3.6.3", | ||
"version": "3.7.0", | ||
"publishConfig": { | ||
@@ -5,0 +5,0 @@ "access": "public" |
@@ -90,2 +90,4 @@ [![npm](https://img.shields.io/npm/v/repository-provider.svg)](https://www.npmjs.com/package/repository-provider) | ||
- [decline](#decline) | ||
- [title](#title) | ||
- [state](#state) | ||
- [RepositoryGroup](#repositorygroup-1) | ||
@@ -100,2 +102,4 @@ - [Parameters](#parameters-10) | ||
- [Properties](#properties-6) | ||
- [propertiesFromOptions](#propertiesfromoptions) | ||
- [Parameters](#parameters-12) | ||
@@ -311,3 +315,3 @@ ## Provider | ||
- `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** | ||
- `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** (optional, default `{}`) | ||
- `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** | ||
- `options.title` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** | ||
@@ -344,2 +348,14 @@ - `options.state` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** | ||
## title | ||
the description of the pull request. | ||
Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** | ||
## state | ||
state of the pull request. | ||
Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** | ||
## RepositoryGroup | ||
@@ -400,2 +416,14 @@ | ||
## propertiesFromOptions | ||
- **See: Object.definedProperties()** | ||
create properties from options and default options | ||
### Parameters | ||
- `properties` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** where the properties will be stored | ||
- `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** | ||
- `defaultOptions` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** | ||
# install | ||
@@ -402,0 +430,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { notImplementedError } from './util'; | ||
import { notImplementedError, propertiesFromOptions } from "./util"; | ||
@@ -19,19 +19,28 @@ /** | ||
export class PullRequest { | ||
constructor(repository, name, options = {}) { | ||
Object.defineProperties( | ||
this, | ||
['title', 'state'].reduce( | ||
(a, key) => { | ||
if (options[key] !== undefined) { | ||
a[key] = { value: options[key] }; | ||
} | ||
return a; | ||
}, | ||
{ | ||
name: { value: name }, | ||
repository: { value: repository } | ||
} | ||
) | ||
); | ||
static get defaultOptions() { | ||
return { | ||
/** | ||
* the description of the pull request. | ||
* @return {string} | ||
*/ | ||
title: undefined, | ||
/** | ||
* state of the pull request. | ||
* @return {string} | ||
*/ | ||
state: undefined | ||
}; | ||
} | ||
constructor(repository, name, options) { | ||
const properties = { | ||
name: { value: name }, | ||
repository: { value: repository } | ||
}; | ||
propertiesFromOptions(properties, options, this.constructor.defaultOptions); | ||
Object.defineProperties(this, properties); | ||
repository.addPullRequest(this); | ||
@@ -38,0 +47,0 @@ } |
@@ -5,2 +5,9 @@ export function notImplementedError() { | ||
/** | ||
* create properties from options and default options | ||
* @see Object.definedProperties() | ||
* @param {Object} properties where the properties will be stored | ||
* @param {Object} options | ||
* @param {Object} defaultOptions | ||
*/ | ||
export function propertiesFromOptions(properties, options, defaultOptions) { | ||
@@ -7,0 +14,0 @@ Object.keys(defaultOptions).forEach(name => { |
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
53876
1292
435