repository-provider
Advanced tools
Comparing version 5.1.2 to 5.2.0
@@ -332,3 +332,9 @@ 'use strict'; | ||
class Content { | ||
constructor(path, content = undefined, type = "blob", mode = "100644") { | ||
static get TYPE_BLOB() { | ||
return "blob"; | ||
} | ||
static get TYPE_TREE() { | ||
return "tree"; | ||
} | ||
constructor(path, content = undefined, type = Content.TYPE_BLOB, mode = "100644") { | ||
Object.defineProperties(this, { | ||
@@ -351,4 +357,20 @@ path: { | ||
get isDirectory() { | ||
return this.type === "tree"; | ||
return this.type === Content.TYPE_TREE; | ||
} | ||
equals(other) { | ||
if (other === undefined || this.path !== other.path || this.type !== other.type || this.mode !== other.mode) { | ||
return false; | ||
} | ||
if (Buffer.isBuffer(this.content)) { | ||
if (Buffer.isBuffer(other.content)) { | ||
return this.content.equals(other.content); | ||
} | ||
} else { | ||
if (this.content === undefined && other.content === undefined) { | ||
return true; | ||
} | ||
} | ||
console.log(`not implemented: ${typeof this.content} <> ${typeof other.content}`); | ||
return false; | ||
} | ||
} | ||
@@ -355,0 +377,0 @@ function emptyContent(path, options) { |
{ | ||
"name": "repository-provider", | ||
"version": "5.1.2", | ||
"version": "5.2.0", | ||
"publishConfig": { | ||
@@ -35,3 +35,3 @@ "access": "public" | ||
"devDependencies": { | ||
"@babel/plugin-proposal-async-generator-functions": "^7.0.0", | ||
"@babel/plugin-proposal-async-generator-functions": "^7.1.0", | ||
"ava": "^1.0.0-beta.8", | ||
@@ -41,3 +41,3 @@ "documentation": "^8.1.2", | ||
"nyc": "^13.1.0", | ||
"rollup": "^0.66.1", | ||
"rollup": "^0.66.2", | ||
"rollup-plugin-babel": "^4.0.3", | ||
@@ -51,3 +51,4 @@ "rollup-plugin-cleanup": "^3.0.0", | ||
"semantic-release": "^15.9.16", | ||
"travis-deploy-once": "^5.0.8" | ||
"travis-deploy-once": "^5.0.9", | ||
"rollup-plugin-json": "^3.1.0" | ||
}, | ||
@@ -54,0 +55,0 @@ "engines": { |
@@ -102,6 +102,8 @@ [![npm](https://img.shields.io/npm/v/repository-provider.svg)](https://www.npmjs.com/package/repository-provider) | ||
- [Properties](#properties-6) | ||
- [equals](#equals) | ||
- [Parameters](#parameters-12) | ||
- [emptyContent](#emptycontent) | ||
- [Parameters](#parameters-12) | ||
- [Parameters](#parameters-13) | ||
- [propertiesFromOptions](#propertiesfromoptions) | ||
- [Parameters](#parameters-13) | ||
- [Parameters](#parameters-14) | ||
@@ -414,3 +416,3 @@ ## Provider | ||
- `content` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \| [Buffer](https://nodejs.org/api/buffer.html) \| [Stream](https://nodejs.org/api/stream.html))** (optional, default `undefined`) | ||
- `type` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** type of the content (optional, default `"blob"`) | ||
- `type` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** type of the content (optional, default `Content.TYPE_BLOB`) | ||
- `mode` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** file permissions (optional, default `"100644"`) | ||
@@ -425,2 +427,12 @@ | ||
### equals | ||
compare against other content | ||
#### Parameters | ||
- `other` **[Content](#content)** | ||
Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true if other describes the same content | ||
## emptyContent | ||
@@ -427,0 +439,0 @@ |
@@ -163,2 +163,3 @@ import { notImplementedError } from "./util"; | ||
* List paths of the branch | ||
* @param {string[]} matchingPatterns | ||
* @return {string[]} all file names in the branch | ||
@@ -165,0 +166,0 @@ */ |
@@ -14,3 +14,15 @@ /** | ||
export class Content { | ||
constructor(path, content = undefined, type = "blob", mode = "100644") { | ||
static get TYPE_BLOB() { | ||
return "blob"; | ||
} | ||
static get TYPE_TREE() { | ||
return "tree"; | ||
} | ||
constructor( | ||
path, | ||
content = undefined, | ||
type = Content.TYPE_BLOB, | ||
mode = "100644" | ||
) { | ||
Object.defineProperties(this, { | ||
@@ -25,4 +37,34 @@ path: { value: path }, | ||
get isDirectory() { | ||
return this.type === "tree"; | ||
return this.type === Content.TYPE_TREE; | ||
} | ||
/** | ||
* compare against other content | ||
* @param {Content} other | ||
* @return {boolean} true if other describes the same content | ||
*/ | ||
equals(other) { | ||
if ( | ||
other === undefined || | ||
this.path !== other.path || | ||
this.type !== other.type || | ||
this.mode !== other.mode | ||
) { | ||
return false; | ||
} | ||
if (Buffer.isBuffer(this.content)) { | ||
if (Buffer.isBuffer(other.content)) { | ||
return this.content.equals(other.content); | ||
} | ||
} else { | ||
if (this.content === undefined && other.content === undefined) { | ||
return true; | ||
} | ||
} | ||
console.log(`not implemented: ${typeof this.content} <> ${typeof other.content}`); | ||
return false; | ||
} | ||
} | ||
@@ -29,0 +71,0 @@ |
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
59954
1522
467
16