Einkaufslisten anzeigen, Datenbankeinbindung

This commit is contained in:
Lukas Nowy
2018-10-27 01:10:46 +02:00
parent 5e3c83707f
commit 8e7d96310f
425 changed files with 77158 additions and 3 deletions

6
express-server/node_modules/pg/.eslintrc generated vendored Normal file
View File

@ -0,0 +1,6 @@
{
"extends": "standard",
"rules": {
"no-new-func": "off"
}
}

41
express-server/node_modules/pg/.travis.yml generated vendored Normal file
View File

@ -0,0 +1,41 @@
language: node_js
sudo: false
dist: trusty
before_script:
- node script/create-test-tables.js pg://postgres@127.0.0.1:5432/postgres
env:
- CC=clang CXX=clang++ npm_config_clang=1 PGUSER=postgres PGDATABASE=postgres
matrix:
include:
- node_js: "lts/boron"
addons:
postgresql: "9.6"
- node_js: "lts/argon"
addons:
postgresql: "9.6"
- node_js: "10"
addons:
postgresql: "9.6"
- node_js: "11"
addons:
postgresql: "9.6"
- node_js: "lts/carbon"
addons:
postgresql: "9.1"
dist: precise
- node_js: "lts/carbon"
addons:
postgresql: "9.2"
- node_js: "lts/carbon"
addons:
postgresql: "9.3"
- node_js: "lts/carbon"
addons:
postgresql: "9.4"
- node_js: "lts/carbon"
addons:
postgresql: "9.5"
- node_js: "lts/carbon"
addons:
postgresql: "9.6"

282
express-server/node_modules/pg/CHANGELOG.md generated vendored Normal file
View File

@ -0,0 +1,282 @@
All major and minor releases are briefly explained below.
For richer information consult the commit log on github with referenced pull requests.
We do not include break-fix version release in this file.
### 7.6.0
- Add support for ["bring your own promise"](https://github.com/brianc/node-postgres/pull/1518)
### 7.5.0
- Better [error message](https://github.com/brianc/node-postgres/commit/11a4793452d618c53e019416cc886ad38deb1aa7) when passing `null` or `undefined` to `client.query`.
- Better [error handling](https://github.com/brianc/node-postgres/pull/1503) on queued queries.
### 7.4.0
- Add support for [Uint8Array](https://github.com/brianc/node-postgres/pull/1448) values.
### 7.3.0
- Add support for [statement timeout](https://github.com/brianc/node-postgres/pull/1436).
### 7.2.0
- Pinned pg-pool and pg-types to a tighter semver range. This is likely not a noticeable change for you unless you were specifically installing older versions of those libraries for some reason, but making it a minor bump here just in case it could cause any confusion.
### 7.1.0
#### Enhancements
- [You can now supply both a connection string and additional config options to clients.](https://github.com/brianc/node-postgres/pull/1363)
### 7.0.0
#### Breaking Changes
- Drop support for node < `4.x`.
- Remove `pg.connect` `pg.end` and `pg.cancel` singleton methods.
- `Client#connect(callback)` now returns `undefined`. It used to return an event emitter.
- Upgrade [pg-pool](https://github.com/brianc/node-pg-pool) to `2.x`.
- Upgrade [pg-native](https://github.com/brianc/node-pg-native) to `2.x`.
- Standardize error message fields between JS and native driver. The only breaking changes were in the native driver as its field names were brought into alignment with the existing JS driver field names.
- Result from multi-statement text queries such as `SELECT 1; SELECT 2;` are now returned as an array of results instead of a single result with 1 array containing rows from both queries.
[Please see here for a migration guide](https://node-postgres.com/guides/upgrading)
#### Enhancements
- Overhauled documentation: [https://node-postgres.com](https://node-postgres.com).
- Add `Client#connect() => Promise<void>` and `Client#end() => Promise<void>` calls. Promises are now returned from all async methods on clients _if and only if_ no callback was supplied to the method.
- Add `connectionTimeoutMillis` to pg-pool.
### v6.2.0
- Add support for [parsing `replicationStart` messages](https://github.com/brianc/node-postgres/pull/1271/files).
### v6.1.0
- Add optional callback parameter to the pure JavaScript `client.end` method. The native client already supported this.
### v6.0.0
#### Breaking Changes
- Remove `pg.pools`. There is still a reference kept to the pools created & tracked by `pg.connect` but it has been renamed, is considered private, and should not be used. Accessing this API directly was uncommon and was _supposed_ to be private but was incorrectly documented on the wiki. Therefore, it is a breaking change of an (unintentionally) public interface to remove it by renaming it & making it private. Eventually `pg.connect` itself will be deprecated in favor of instantiating pools directly via `new pg.Pool()` so this property should become completely moot at some point. In the mean time...check out the new features...
#### New features
- Replace internal pooling code with [pg-pool](https://github.com/brianc/node-pg-pool). This is the first step in eventually deprecating and removing the singleton `pg.connect`. The pg-pool constructor is exported from node-postgres at `require('pg').Pool`. It provides a backwards compatible interface with `pg.connect` as well as a promise based interface & additional niceties.
You can now create an instance of a pool and don't have to rely on the `pg` singleton for anything:
```
var pg = require('pg')
var pool = new pg.Pool()
// your friendly neighborhood pool interface, without the singleton
pool.connect(function(err, client, done) {
// ...
})
```
Promise support & other goodness lives now in [pg-pool](https://github.com/brianc/node-pg-pool).
__Please__ read the readme at [pg-pool](https://github.com/brianc/node-pg-pool) for the full api.
- Included support for tcp keep alive. Enable it as follows:
```js
var client = new Client({ keepAlive: true })
```
This should help with backends incorrectly considering idle clients to be dead and prematurely disconnecting them.
### v5.1.0
- Make the query object returned from `client.query` implement the promise interface. This is the first step towards promisifying more of the node-postgres api.
Example:
```js
var client = new Client()
client.connect()
client.query('SELECT $1::text as name', ['brianc'])
.then(function(res) {
console.log('hello from', res.rows[0])
client.end()
})
```
### v5.0.0
#### Breaking Changes
- `require('pg').native` now returns null if the native bindings cannot be found; previously, this threw an exception.
#### New Features
- better error message when passing `undefined` as a query parameter
- support for `defaults.connectionString`
- support for `returnToHead` being passed to [generic pool](https://github.com/coopernurse/node-pool)
### v4.5.0
- Add option to parse JS date objects in query parameters as [UTC](https://github.com/brianc/node-postgres/pull/943)
### v4.4.0
- Warn to `stderr` if a named query exceeds 63 characters which is the max length supported by postgres.
### v4.3.0
- Unpin `pg-types` semver. Allow it to float against `pg-types@1.x`.
### v4.2.0
- Support for additional error fields in postgres >= 9.3 if available.
### v4.1.0
- Allow type parser overrides on a [per-client basis](https://github.com/brianc/node-postgres/pull/679)
### v4.0.0
- Make [native bindings](https://github.com/brianc/node-pg-native.git) an optional install with `npm install pg-native`
- No longer surround query result callback with `try/catch` block.
- Remove built in COPY IN / COPY OUT support - better implementations provided by [pg-copy-streams](https://github.com/brianc/node-pg-copy-streams.git) and [pg-native](https://github.com/brianc/node-pg-native.git)
### v3.6.0
- Include support for (parsing JSONB)[https://github.com/brianc/node-pg-types/pull/13] (supported in postgres 9.4)
### v3.5.0
- Include support for parsing boolean arrays
### v3.4.0
- Include port as connection parameter to [unix sockets](https://github.com/brianc/node-postgres/pull/604)
- Better support for odd [date parsing](https://github.com/brianc/node-pg-types/pull/8)
### v3.2.0
- Add support for parsing [date arrays](https://github.com/brianc/node-pg-types/pull/3)
- Expose array parsers on [pg.types](https://github.com/brianc/node-pg-types/pull/2)
- Allow [pool](https://github.com/brianc/node-postgres/pull/591) to be configured
### v3.1.0
- Add [count of the number of times a client has been checked out from the pool](https://github.com/brianc/node-postgres/pull/556)
- Emit `end` from `pg` object [when a pool is drained](https://github.com/brianc/node-postgres/pull/571)
### v3.0.0
#### Breaking changes
- [Parse the DATE PostgreSQL type as local time](https://github.com/brianc/node-postgres/pull/514)
After [some discussion](https://github.com/brianc/node-postgres/issues/510) it was decided node-postgres was non-compliant in how it was handling DATE results. They were being converted to UTC, but the PostgreSQL documentation specifies they should be returned in the client timezone. This is a breaking change, and if you use the `date` type you might want to examine your code and make sure nothing is impacted.
- [Fix possible numeric precision loss on numeric & int8 arrays](https://github.com/brianc/node-postgres/pull/501)
pg@v2.0 included changes to not convert large integers into their JavaScript number representation because of possibility for numeric precision loss. The same types in arrays were not taken into account. This fix applies the same type of type-coercion rules to arrays of those types, so there will be no more possible numeric loss on an array of very large int8s for example. This is a breaking change because now a return type from a query of `int8[]` will contain _string_ representations
of the integers. Use your favorite JavaScript bignum module to represent them without precision loss, or punch over the type converter to return the old style arrays again.
- [Fix to input array of dates being improperly converted to utc](https://github.com/benesch/node-postgres/commit/c41eedc3e01e5527a3d5c242fa1896f02ef0b261#diff-7172adb1fec2457a2700ed29008a8e0aR108)
Single `date` parameters were properly sent to the PostgreSQL server properly in local time, but an input array of dates was being changed into utc dates. This is a violation of what PostgreSQL expects. Small breaking change, but none-the-less something you should check out if you are inserting an array of dates.
- [Query no longer emits `end` event if it ends due to an error](https://github.com/brianc/node-postgres/commit/357b64d70431ec5ca721eb45a63b082c18e6ffa3)
This is a small change to bring the semantics of query more in line with other EventEmitters. The tests all passed after this change, but I suppose it could still be a breaking change in certain use cases. If you are doing clever things with the `end` and `error` events of a query object you might want to check to make sure its still behaving normally, though it is most likely not an issue.
#### New features
- [Supercharge `prepareValue`](https://github.com/brianc/node-postgres/pull/555)
The long & short of it is now any object you supply in the list of query values will be inspected for a `.toPostgres` method. If the method is present it will be called and its result used as the raw text value sent to PostgreSQL for that value. This allows the same type of custom type coercion on query parameters as was previously afforded to query result values.
- [Domain aware connection pool](https://github.com/brianc/node-postgres/pull/531)
If domains are active node-postgres will honor them and do everything it can to ensure all callbacks are properly fired in the active domain. If you have tried to use domains with node-postgres (or many other modules which pool long lived event emitters) you may have run into an issue where the active domain changes before and after a callback. This has been a longstanding footgun within node-postgres and I am happy to get it fixed.
- [Disconnected clients now removed from pool](https://github.com/brianc/node-postgres/pull/543)
Avoids a scenario where your pool could fill up with disconnected & unusable clients.
- [Break type parsing code into separate module](https://github.com/brianc/node-postgres/pull/541)
To provide better documentation and a clearer explanation of how to override the query result parsing system we broke the type converters [into their own module](https://github.com/brianc/node-pg-types). There is still work around removing the 'global-ness' of the type converters so each query or connection can return types differently, but this is a good first step and allow a lot more obvious way to return int8 results as JavaScript numbers, for example
### v2.11.0
- Add support for [application_name](https://github.com/brianc/node-postgres/pull/497)
### v2.10.0
- Add support for [the password file](http://www.postgresql.org/docs/9.3/static/libpq-pgpass.html)
### v2.9.0
- Add better support for [unix domain socket](https://github.com/brianc/node-postgres/pull/487) connections
### v2.8.0
- Add support for parsing JSON[] and UUID[] result types
### v2.7.0
- Use single row mode in native bindings when available [@rpedela]
- reduces memory consumption when handling row values in 'row' event
- Automatically bind buffer type parameters as binary [@eugeneware]
### v2.6.0
- Respect PGSSLMODE environment variable
### v2.5.0
- Ability to opt-in to int8 parsing via `pg.defaults.parseInt8 = true`
### v2.4.0
- Use eval in the result set parser to increase performance
### v2.3.0
- Remove built-in support for binary Int64 parsing.
_Due to the low usage & required compiled dependency this will be pushed into a 3rd party add-on_
### v2.2.0
- [Add support for excapeLiteral and escapeIdentifier in both JavaScript and the native bindings](https://github.com/brianc/node-postgres/pull/396)
### v2.1.0
- Add support for SSL connections in JavaScript driver
- this means you can connect to heroku postgres from your local machine without the native bindings!
- [Add field metadata to result object](https://github.com/brianc/node-postgres/blob/master/test/integration/client/row-description-on-results-tests.js)
- [Add ability for rows to be returned as arrays instead of objects](https://github.com/brianc/node-postgres/blob/master/test/integration/client/results-as-array-tests.js)
### v2.0.0
- Properly handle various PostgreSQL to JavaScript type conversions to avoid data loss:
```
PostgreSQL | pg@v2.0 JavaScript | pg@v1.0 JavaScript
--------------------------------|----------------
float4 | number (float) | string
float8 | number (float) | string
int8 | string | number (int)
numeric | string | number (float)
decimal | string | number (float)
```
For more information see https://github.com/brianc/node-postgres/pull/353
If you are unhappy with these changes you can always [override the built in type parsing fairly easily](https://github.com/brianc/node-pg-parse-float).
### v1.3.0
- Make client_encoding configurable and optional
### v1.2.0
- return field metadata on result object: access via result.fields[i].name/dataTypeID
### v1.1.0
- built in support for `JSON` data type for PostgreSQL Server @ v9.2.0 or greater
### v1.0.0
- remove deprecated functionality
- Callback function passed to `pg.connect` now __requires__ 3 arguments
- Client#pauseDrain() / Client#resumeDrain removed
- numeric, decimal, and float data types no longer parsed into float before being returned. Will be returned from query results as `String`
### v0.15.0
- client now emits `end` when disconnected from back-end server
- if client is disconnected in the middle of a query, query receives an error
### v0.14.0
- add deprecation warnings in prep for v1.0
- fix read/write failures in native module under node v0.9.x

21
express-server/node_modules/pg/LICENSE generated vendored Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2010 - 2018 Brian Carlson
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

65
express-server/node_modules/pg/Makefile generated vendored Normal file
View File

@ -0,0 +1,65 @@
SHELL := /bin/sh
connectionString=postgres://
params := $(connectionString)
node-command := xargs -n 1 -I file node file $(params)
.PHONY : test test-connection test-integration bench test-native \
lint publish test-missing-native update-npm
all:
npm install
help:
@echo "make test-all [connectionString=postgres://<your connection string>]"
test: test-unit
test-all: lint test-missing-native test-unit test-integration test-native
update-npm:
@npm i npm --global
bench:
@find benchmark -name "*-bench.js" | $(node-command)
test-unit:
@find test/unit -name "*-tests.js" | $(node-command)
test-connection:
@echo "***Testing connection***"
@node script/create-test-tables.js $(params)
test-missing-native:
@echo "***Testing optional native install***"
@rm -rf node_modules/pg-native
@rm -rf node_modules/libpq
@node test/native/missing-native.js
@rm -rf node_modules/pg-native
@rm -rf node_modules/libpq
node_modules/pg-native/index.js:
@npm i --no-save pg-native
test-native: node_modules/pg-native/index.js test-connection
@echo "***Testing native bindings***"
@find test/native -name "*-tests.js" | $(node-command)
@find test/integration -name "*-tests.js" | $(node-command) native
test-integration: test-connection
@echo "***Testing Pure Javascript***"
@find test/integration -name "*-tests.js" | $(node-command)
test-binary: test-connection
@echo "***Testing Pure Javascript (binary)***"
@find test/integration -name "*-tests.js" | $(node-command) binary
test-pool:
@find test/integration/connection-pool -name "*.js" | $(node-command) binary
lint:
@echo "***Starting lint***"
node_modules/.bin/eslint lib

88
express-server/node_modules/pg/README.md generated vendored Normal file
View File

@ -0,0 +1,88 @@
# node-postgres
[![Build Status](https://secure.travis-ci.org/brianc/node-postgres.svg?branch=master)](http://travis-ci.org/brianc/node-postgres)
[![Dependency Status](https://david-dm.org/brianc/node-postgres.svg)](https://david-dm.org/brianc/node-postgres)
<span class="badge-npmversion"><a href="https://npmjs.org/package/pg" title="View this project on NPM"><img src="https://img.shields.io/npm/v/pg.svg" alt="NPM version" /></a></span>
<span class="badge-npmdownloads"><a href="https://npmjs.org/package/pg" title="View this project on NPM"><img src="https://img.shields.io/npm/dm/pg.svg" alt="NPM downloads" /></a></span>
Non-blocking PostgreSQL client for Node.js. Pure JavaScript and optional native libpq bindings.
## Install
```sh
$ npm install pg
```
---
## :star: [Documentation](https://node-postgres.com) :star:
### Features
* Pure JavaScript client and native libpq bindings share _the same API_
* Connection pooling
* Extensible JS<->PostgreSQL data-type coercion
* Supported PostgreSQL features
* Parameterized queries
* Named statements with query plan caching
* Async notifications with `LISTEN/NOTIFY`
* Bulk import & export with `COPY TO/COPY FROM`
### Extras
node-postgres is by design pretty light on abstractions. These are some handy modules we've been using over the years to complete the picture.
The entire list can be found on our [wiki](https://github.com/brianc/node-postgres/wiki/Extras).
## Support
node-postgres is free software. If you encounter a bug with the library please open an issue on the [GitHub repo](https://github.com/brianc/node-postgres). If you have questions unanswered by the documentation please open an issue pointing out how the documentation was unclear & I will do my best to make it better!
When you open an issue please provide:
- version of Node
- version of Postgres
- smallest possible snippet of code to reproduce the problem
You can also follow me [@briancarlson](https://twitter.com/briancarlson) if that's your thing. I try to always announce noteworthy changes & developments with node-postgres on Twitter.
### Professional Support
I offer professional support for node-postgres. I provide implementation, training, and many years of expertise on how to build applications with Node, Express, PostgreSQL, and React/Redux. Please contact me at [brian.m.carlson@gmail.com](mailto:brian.m.carlson@gmail.com) to discuss how I can help your company be more successful!
### Sponsorship :star:
If you are benefiting from node-postgres and would like to help keep the project financially sustainable please visit Brian Carlson's [Patreon page](https://www.patreon.com/node_postgres).
## Contributing
__:heart: contributions!__
I will __happily__ accept your pull request if it:
- __has tests__
- looks reasonable
- does not break backwards compatibility
## Troubleshooting and FAQ
The causes and solutions to common errors can be found among the [Frequently Asked Questions (FAQ)](https://github.com/brianc/node-postgres/wiki/FAQ)
## License
Copyright (c) 2010-2018 Brian Carlson (brian.m.carlson@gmail.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

19
express-server/node_modules/pg/SPONSORS.md generated vendored Normal file
View File

@ -0,0 +1,19 @@
node-postgres is made possible by the helpful contributors from the community well as the following generous supporters on [Patreon](https://www.patreon.com/node_postgres).
# Leaders
- [MadKudu](https://www.madkudu.com) - [@madkudu](https://twitter.com/madkudu)
# Supporters
- John Fawcett
- Lalit Kapoor [@lalitkapoor](https://twitter.com/lalitkapoor)
- Paul Frazee [@pfrazee](https://twitter.com/pfrazee)
- Rein Petersen
- Arnaud Benhamdine [@abenhamdine](https://twitter.com/abenhamdine)
- Matthew Welke
- Matthew Weber
- Andrea De Simon
- Todd Kennedy
- Alexander Robson
- Benjie Gillam
- David Hanson
- Franklin Davenport

468
express-server/node_modules/pg/lib/client.js generated vendored Normal file
View File

@ -0,0 +1,468 @@
'use strict'
/**
* Copyright (c) 2010-2017 Brian Carlson (brian.m.carlson@gmail.com)
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* README.md file in the root directory of this source tree.
*/
var EventEmitter = require('events').EventEmitter
var util = require('util')
var utils = require('./utils')
var pgPass = require('pgpass')
var TypeOverrides = require('./type-overrides')
var ConnectionParameters = require('./connection-parameters')
var Query = require('./query')
var defaults = require('./defaults')
var Connection = require('./connection')
var Client = function (config) {
EventEmitter.call(this)
this.connectionParameters = new ConnectionParameters(config)
this.user = this.connectionParameters.user
this.database = this.connectionParameters.database
this.port = this.connectionParameters.port
this.host = this.connectionParameters.host
this.password = this.connectionParameters.password
this.replication = this.connectionParameters.replication
var c = config || {}
this._Promise = c.Promise || global.Promise
this._types = new TypeOverrides(c.types)
this._ending = false
this._connecting = false
this._connected = false
this._connectionError = false
this._queryable = true
this.connection = c.connection || new Connection({
stream: c.stream,
ssl: this.connectionParameters.ssl,
keepAlive: c.keepAlive || false,
encoding: this.connectionParameters.client_encoding || 'utf8'
})
this.queryQueue = []
this.binary = c.binary || defaults.binary
this.processID = null
this.secretKey = null
this.ssl = this.connectionParameters.ssl || false
}
util.inherits(Client, EventEmitter)
Client.prototype._errorAllQueries = function (err) {
const enqueueError = (query) => {
process.nextTick(() => {
query.handleError(err, this.connection)
})
}
if (this.activeQuery) {
enqueueError(this.activeQuery)
this.activeQuery = null
}
this.queryQueue.forEach(enqueueError)
this.queryQueue.length = 0
}
Client.prototype._connect = function (callback) {
var self = this
var con = this.connection
if (this._connecting || this._connected) {
const err = new Error('Client has already been connected. You cannot reuse a client.')
process.nextTick(() => {
callback(err)
})
return
}
this._connecting = true
if (this.host && this.host.indexOf('/') === 0) {
con.connect(this.host + '/.s.PGSQL.' + this.port)
} else {
con.connect(this.port, this.host)
}
// once connection is established send startup message
con.on('connect', function () {
if (self.ssl) {
con.requestSsl()
} else {
con.startup(self.getStartupConf())
}
})
con.on('sslconnect', function () {
con.startup(self.getStartupConf())
})
function checkPgPass (cb) {
return function (msg) {
if (self.password !== null) {
cb(msg)
} else {
pgPass(self.connectionParameters, function (pass) {
if (undefined !== pass) {
self.connectionParameters.password = self.password = pass
}
cb(msg)
})
}
}
}
// password request handling
con.on('authenticationCleartextPassword', checkPgPass(function () {
con.password(self.password)
}))
// password request handling
con.on('authenticationMD5Password', checkPgPass(function (msg) {
con.password(utils.postgresMd5PasswordHash(self.user, self.password, msg.salt))
}))
con.once('backendKeyData', function (msg) {
self.processID = msg.processID
self.secretKey = msg.secretKey
})
const connectingErrorHandler = (err) => {
if (this._connectionError) {
return
}
this._connectionError = true
if (callback) {
return callback(err)
}
this.emit('error', err)
}
const connectedErrorHandler = (err) => {
this._queryable = false
this._errorAllQueries(err)
this.emit('error', err)
}
const connectedErrorMessageHandler = (msg) => {
const activeQuery = this.activeQuery
if (!activeQuery) {
connectedErrorHandler(msg)
return
}
this.activeQuery = null
activeQuery.handleError(msg, con)
}
con.on('error', connectingErrorHandler)
con.on('errorMessage', connectingErrorHandler)
// hook up query handling events to connection
// after the connection initially becomes ready for queries
con.once('readyForQuery', function () {
self._connecting = false
self._connected = true
self._attachListeners(con)
con.removeListener('error', connectingErrorHandler)
con.removeListener('errorMessage', connectingErrorHandler)
con.on('error', connectedErrorHandler)
con.on('errorMessage', connectedErrorMessageHandler)
// process possible callback argument to Client#connect
if (callback) {
callback(null, self)
// remove callback for proper error handling
// after the connect event
callback = null
}
self.emit('connect')
})
con.on('readyForQuery', function () {
var activeQuery = self.activeQuery
self.activeQuery = null
self.readyForQuery = true
if (activeQuery) {
activeQuery.handleReadyForQuery(con)
}
self._pulseQueryQueue()
})
con.once('end', () => {
const error = this._ending
? new Error('Connection terminated')
: new Error('Connection terminated unexpectedly')
this._errorAllQueries(error)
if (!this._ending) {
// if the connection is ended without us calling .end()
// on this client then we have an unexpected disconnection
// treat this as an error unless we've already emitted an error
// during connection.
if (this._connecting && !this._connectionError) {
if (callback) {
callback(error)
} else {
connectedErrorHandler(error)
}
} else if (!this._connectionError) {
connectedErrorHandler(error)
}
}
process.nextTick(() => {
this.emit('end')
})
})
con.on('notice', function (msg) {
self.emit('notice', msg)
})
}
Client.prototype.connect = function (callback) {
if (callback) {
this._connect(callback)
return
}
return new this._Promise((resolve, reject) => {
this._connect((error) => {
if (error) {
reject(error)
} else {
resolve()
}
})
})
}
Client.prototype._attachListeners = function (con) {
const self = this
// delegate rowDescription to active query
con.on('rowDescription', function (msg) {
self.activeQuery.handleRowDescription(msg)
})
// delegate dataRow to active query
con.on('dataRow', function (msg) {
self.activeQuery.handleDataRow(msg)
})
// delegate portalSuspended to active query
con.on('portalSuspended', function (msg) {
self.activeQuery.handlePortalSuspended(con)
})
// deletagate emptyQuery to active query
con.on('emptyQuery', function (msg) {
self.activeQuery.handleEmptyQuery(con)
})
// delegate commandComplete to active query
con.on('commandComplete', function (msg) {
self.activeQuery.handleCommandComplete(msg, con)
})
// if a prepared statement has a name and properly parses
// we track that its already been executed so we don't parse
// it again on the same client
con.on('parseComplete', function (msg) {
if (self.activeQuery.name) {
con.parsedStatements[self.activeQuery.name] = true
}
})
con.on('copyInResponse', function (msg) {
self.activeQuery.handleCopyInResponse(self.connection)
})
con.on('copyData', function (msg) {
self.activeQuery.handleCopyData(msg, self.connection)
})
con.on('notification', function (msg) {
self.emit('notification', msg)
})
}
Client.prototype.getStartupConf = function () {
var params = this.connectionParameters
var data = {
user: params.user,
database: params.database
}
var appName = params.application_name || params.fallback_application_name
if (appName) {
data.application_name = appName
}
if (params.replication) {
data.replication = '' + params.replication
}
if (params.statement_timeout) {
data.statement_timeout = String(parseInt(params.statement_timeout, 10))
}
return data
}
Client.prototype.cancel = function (client, query) {
if (client.activeQuery === query) {
var con = this.connection
if (this.host && this.host.indexOf('/') === 0) {
con.connect(this.host + '/.s.PGSQL.' + this.port)
} else {
con.connect(this.port, this.host)
}
// once connection is established send cancel message
con.on('connect', function () {
con.cancel(client.processID, client.secretKey)
})
} else if (client.queryQueue.indexOf(query) !== -1) {
client.queryQueue.splice(client.queryQueue.indexOf(query), 1)
}
}
Client.prototype.setTypeParser = function (oid, format, parseFn) {
return this._types.setTypeParser(oid, format, parseFn)
}
Client.prototype.getTypeParser = function (oid, format) {
return this._types.getTypeParser(oid, format)
}
// Ported from PostgreSQL 9.2.4 source code in src/interfaces/libpq/fe-exec.c
Client.prototype.escapeIdentifier = function (str) {
return '"' + str.replace(/"/g, '""') + '"'
}
// Ported from PostgreSQL 9.2.4 source code in src/interfaces/libpq/fe-exec.c
Client.prototype.escapeLiteral = function (str) {
var hasBackslash = false
var escaped = '\''
for (var i = 0; i < str.length; i++) {
var c = str[i]
if (c === '\'') {
escaped += c + c
} else if (c === '\\') {
escaped += c + c
hasBackslash = true
} else {
escaped += c
}
}
escaped += '\''
if (hasBackslash === true) {
escaped = ' E' + escaped
}
return escaped
}
Client.prototype._pulseQueryQueue = function () {
if (this.readyForQuery === true) {
this.activeQuery = this.queryQueue.shift()
if (this.activeQuery) {
this.readyForQuery = false
this.hasExecuted = true
const queryError = this.activeQuery.submit(this.connection)
if (queryError) {
process.nextTick(() => {
this.activeQuery.handleError(queryError, this.connection)
this.readyForQuery = true
this._pulseQueryQueue()
})
}
} else if (this.hasExecuted) {
this.activeQuery = null
this.emit('drain')
}
}
}
Client.prototype.query = function (config, values, callback) {
// can take in strings, config object or query object
var query
var result
if (config === null || config === undefined) {
throw new TypeError('Client was passed a null or undefined query')
} else if (typeof config.submit === 'function') {
result = query = config
if (typeof values === 'function') {
query.callback = query.callback || values
}
} else {
query = new Query(config, values, callback)
if (!query.callback) {
result = new this._Promise((resolve, reject) => {
query.callback = (err, res) => err ? reject(err) : resolve(res)
})
}
}
if (this.binary && !query.binary) {
query.binary = true
}
if (query._result) {
query._result._getTypeParser = this._types.getTypeParser.bind(this._types)
}
if (!this._queryable) {
process.nextTick(() => {
query.handleError(new Error('Client has encountered a connection error and is not queryable'), this.connection)
})
return result
}
if (this._ending) {
process.nextTick(() => {
query.handleError(new Error('Client was closed and is not queryable'), this.connection)
})
return result
}
this.queryQueue.push(query)
this._pulseQueryQueue()
return result
}
Client.prototype.end = function (cb) {
this._ending = true
if (this.activeQuery) {
// if we have an active query we need to force a disconnect
// on the socket - otherwise a hung query could block end forever
this.connection.stream.destroy()
} else {
this.connection.end()
}
if (cb) {
this.connection.once('end', cb)
} else {
return new this._Promise((resolve) => {
this.connection.once('end', resolve)
})
}
}
// expose a Query constructor
Client.Query = Query
module.exports = Client

View File

@ -0,0 +1,119 @@
'use strict'
/**
* Copyright (c) 2010-2017 Brian Carlson (brian.m.carlson@gmail.com)
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* README.md file in the root directory of this source tree.
*/
var dns = require('dns')
var defaults = require('./defaults')
var parse = require('pg-connection-string').parse // parses a connection string
var val = function (key, config, envVar) {
if (envVar === undefined) {
envVar = process.env[ 'PG' + key.toUpperCase() ]
} else if (envVar === false) {
// do nothing ... use false
} else {
envVar = process.env[ envVar ]
}
return config[key] ||
envVar ||
defaults[key]
}
var useSsl = function () {
switch (process.env.PGSSLMODE) {
case 'disable':
return false
case 'prefer':
case 'require':
case 'verify-ca':
case 'verify-full':
return true
}
return defaults.ssl
}
var ConnectionParameters = function (config) {
// if a string is passed, it is a raw connection string so we parse it into a config
config = typeof config === 'string' ? parse(config) : config || {}
// if the config has a connectionString defined, parse IT into the config we use
// this will override other default values with what is stored in connectionString
if (config.connectionString) {
config = Object.assign({}, config, parse(config.connectionString))
}
this.user = val('user', config)
this.database = val('database', config)
this.port = parseInt(val('port', config), 10)
this.host = val('host', config)
this.password = val('password', config)
this.binary = val('binary', config)
this.ssl = typeof config.ssl === 'undefined' ? useSsl() : config.ssl
this.client_encoding = val('client_encoding', config)
this.replication = val('replication', config)
// a domain socket begins with '/'
this.isDomainSocket = (!(this.host || '').indexOf('/'))
this.application_name = val('application_name', config, 'PGAPPNAME')
this.fallback_application_name = val('fallback_application_name', config, false)
this.statement_timeout = val('statement_timeout', config, false)
}
// Convert arg to a string, surround in single quotes, and escape single quotes and backslashes
var quoteParamValue = function (value) {
return "'" + ('' + value).replace(/\\/g, '\\\\').replace(/'/g, "\\'") + "'"
}
var add = function (params, config, paramName) {
var value = config[paramName]
if (value) {
params.push(paramName + '=' + quoteParamValue(value))
}
}
ConnectionParameters.prototype.getLibpqConnectionString = function (cb) {
var params = []
add(params, this, 'user')
add(params, this, 'password')
add(params, this, 'port')
add(params, this, 'application_name')
add(params, this, 'fallback_application_name')
var ssl = typeof this.ssl === 'object' ? this.ssl : { sslmode: this.ssl }
add(params, ssl, 'sslmode')
add(params, ssl, 'sslca')
add(params, ssl, 'sslkey')
add(params, ssl, 'sslcert')
add(params, ssl, 'sslrootcert')
if (this.database) {
params.push('dbname=' + quoteParamValue(this.database))
}
if (this.replication) {
params.push('replication=' + quoteParamValue(this.replication))
}
if (this.host) {
params.push('host=' + quoteParamValue(this.host))
}
if (this.isDomainSocket) {
return cb(null, params.join(' '))
}
if (this.client_encoding) {
params.push('client_encoding=' + quoteParamValue(this.client_encoding))
}
dns.lookup(this.host, function (err, address) {
if (err) return cb(err, null)
params.push('hostaddr=' + quoteParamValue(address))
return cb(null, params.join(' '))
})
}
module.exports = ConnectionParameters

655
express-server/node_modules/pg/lib/connection.js generated vendored Normal file
View File

@ -0,0 +1,655 @@
'use strict'
/**
* Copyright (c) 2010-2017 Brian Carlson (brian.m.carlson@gmail.com)
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* README.md file in the root directory of this source tree.
*/
var net = require('net')
var EventEmitter = require('events').EventEmitter
var util = require('util')
var Writer = require('buffer-writer')
var Reader = require('packet-reader')
var TEXT_MODE = 0
var BINARY_MODE = 1
var Connection = function (config) {
EventEmitter.call(this)
config = config || {}
this.stream = config.stream || new net.Socket()
this._keepAlive = config.keepAlive
this.lastBuffer = false
this.lastOffset = 0
this.buffer = null
this.offset = null
this.encoding = config.encoding || 'utf8'
this.parsedStatements = {}
this.writer = new Writer()
this.ssl = config.ssl || false
this._ending = false
this._mode = TEXT_MODE
this._emitMessage = false
this._reader = new Reader({
headerSize: 1,
lengthPadding: -4
})
var self = this
this.on('newListener', function (eventName) {
if (eventName === 'message') {
self._emitMessage = true
}
})
}
util.inherits(Connection, EventEmitter)
Connection.prototype.connect = function (port, host) {
if (this.stream.readyState === 'closed') {
this.stream.connect(port, host)
} else if (this.stream.readyState === 'open') {
this.emit('connect')
}
var self = this
this.stream.on('connect', function () {
if (self._keepAlive) {
self.stream.setKeepAlive(true)
}
self.emit('connect')
})
const reportStreamError = function (error) {
// don't raise ECONNRESET errors - they can & should be ignored
// during disconnect
if (self._ending && error.code === 'ECONNRESET') {
return
}
self.emit('error', error)
}
this.stream.on('error', reportStreamError)
this.stream.on('close', function () {
self.emit('end')
})
if (!this.ssl) {
return this.attachListeners(this.stream)
}
this.stream.once('data', function (buffer) {
var responseCode = buffer.toString('utf8')
switch (responseCode) {
case 'N': // Server does not support SSL connections
return self.emit('error', new Error('The server does not support SSL connections'))
case 'S': // Server supports SSL connections, continue with a secure connection
break
default: // Any other response byte, including 'E' (ErrorResponse) indicating a server error
return self.emit('error', new Error('There was an error establishing an SSL connection'))
}
var tls = require('tls')
self.stream = tls.connect({
socket: self.stream,
servername: host,
checkServerIdentity: self.ssl.checkServerIdentity || tls.checkServerIdentity,
rejectUnauthorized: self.ssl.rejectUnauthorized,
ca: self.ssl.ca,
pfx: self.ssl.pfx,
key: self.ssl.key,
passphrase: self.ssl.passphrase,
cert: self.ssl.cert,
NPNProtocols: self.ssl.NPNProtocols
})
self.attachListeners(self.stream)
self.stream.on('error', reportStreamError)
self.emit('sslconnect')
})
}
Connection.prototype.attachListeners = function (stream) {
var self = this
stream.on('data', function (buff) {
self._reader.addChunk(buff)
var packet = self._reader.read()
while (packet) {
var msg = self.parseMessage(packet)
var eventName = msg.name === 'error' ? 'errorMessage' : msg.name
if (self._emitMessage) {
self.emit('message', msg)
}
self.emit(eventName, msg)
packet = self._reader.read()
}
})
stream.on('end', function () {
self.emit('end')
})
}
Connection.prototype.requestSsl = function () {
var bodyBuffer = this.writer
.addInt16(0x04D2)
.addInt16(0x162F).flush()
var length = bodyBuffer.length + 4
var buffer = new Writer()
.addInt32(length)
.add(bodyBuffer)
.join()
this.stream.write(buffer)
}
Connection.prototype.startup = function (config) {
var writer = this.writer
.addInt16(3)
.addInt16(0)
Object.keys(config).forEach(function (key) {
var val = config[key]
writer.addCString(key).addCString(val)
})
writer.addCString('client_encoding').addCString("'utf-8'")
var bodyBuffer = writer.addCString('').flush()
// this message is sent without a code
var length = bodyBuffer.length + 4
var buffer = new Writer()
.addInt32(length)
.add(bodyBuffer)
.join()
this.stream.write(buffer)
}
Connection.prototype.cancel = function (processID, secretKey) {
var bodyBuffer = this.writer
.addInt16(1234)
.addInt16(5678)
.addInt32(processID)
.addInt32(secretKey)
.flush()
var length = bodyBuffer.length + 4
var buffer = new Writer()
.addInt32(length)
.add(bodyBuffer)
.join()
this.stream.write(buffer)
}
Connection.prototype.password = function (password) {
// 0x70 = 'p'
this._send(0x70, this.writer.addCString(password))
}
Connection.prototype._send = function (code, more) {
if (!this.stream.writable) {
return false
}
if (more === true) {
this.writer.addHeader(code)
} else {
return this.stream.write(this.writer.flush(code))
}
}
Connection.prototype.query = function (text) {
// 0x51 = Q
this.stream.write(this.writer.addCString(text).flush(0x51))
}
// send parse message
// "more" === true to buffer the message until flush() is called
Connection.prototype.parse = function (query, more) {
// expect something like this:
// { name: 'queryName',
// text: 'select * from blah',
// types: ['int8', 'bool'] }
// normalize missing query names to allow for null
query.name = query.name || ''
if (query.name.length > 63) {
console.error('Warning! Postgres only supports 63 characters for query names.')
console.error('You supplied', query.name, '(', query.name.length, ')')
console.error('This can cause conflicts and silent errors executing queries')
}
// normalize null type array
query.types = query.types || []
var len = query.types.length
var buffer = this.writer
.addCString(query.name) // name of query
.addCString(query.text) // actual query text
.addInt16(len)
for (var i = 0; i < len; i++) {
buffer.addInt32(query.types[i])
}
var code = 0x50
this._send(code, more)
}
// send bind message
// "more" === true to buffer the message until flush() is called
Connection.prototype.bind = function (config, more) {
// normalize config
config = config || {}
config.portal = config.portal || ''
config.statement = config.statement || ''
config.binary = config.binary || false
var values = config.values || []
var len = values.length
var useBinary = false
for (var j = 0; j < len; j++) { useBinary |= values[j] instanceof Buffer }
var buffer = this.writer
.addCString(config.portal)
.addCString(config.statement)
if (!useBinary) { buffer.addInt16(0) } else {
buffer.addInt16(len)
for (j = 0; j < len; j++) { buffer.addInt16(values[j] instanceof Buffer) }
}
buffer.addInt16(len)
for (var i = 0; i < len; i++) {
var val = values[i]
if (val === null || typeof val === 'undefined') {
buffer.addInt32(-1)
} else if (val instanceof Buffer) {
buffer.addInt32(val.length)
buffer.add(val)
} else {
buffer.addInt32(Buffer.byteLength(val))
buffer.addString(val)
}
}
if (config.binary) {
buffer.addInt16(1) // format codes to use binary
buffer.addInt16(1)
} else {
buffer.addInt16(0) // format codes to use text
}
// 0x42 = 'B'
this._send(0x42, more)
}
// send execute message
// "more" === true to buffer the message until flush() is called
Connection.prototype.execute = function (config, more) {
config = config || {}
config.portal = config.portal || ''
config.rows = config.rows || ''
this.writer
.addCString(config.portal)
.addInt32(config.rows)
// 0x45 = 'E'
this._send(0x45, more)
}
var emptyBuffer = Buffer.alloc(0)
Connection.prototype.flush = function () {
// 0x48 = 'H'
this.writer.add(emptyBuffer)
this._send(0x48)
}
Connection.prototype.sync = function () {
// clear out any pending data in the writer
this.writer.flush(0)
this.writer.add(emptyBuffer)
this._ending = true
this._send(0x53)
}
const END_BUFFER = Buffer.from([0x58, 0x00, 0x00, 0x00, 0x04])
Connection.prototype.end = function () {
// 0x58 = 'X'
this.writer.add(emptyBuffer)
this._ending = true
return this.stream.write(END_BUFFER, () => {
this.stream.end()
})
}
Connection.prototype.close = function (msg, more) {
this.writer.addCString(msg.type + (msg.name || ''))
this._send(0x43, more)
}
Connection.prototype.describe = function (msg, more) {
this.writer.addCString(msg.type + (msg.name || ''))
this._send(0x44, more)
}
Connection.prototype.sendCopyFromChunk = function (chunk) {
this.stream.write(this.writer.add(chunk).flush(0x64))
}
Connection.prototype.endCopyFrom = function () {
this.stream.write(this.writer.add(emptyBuffer).flush(0x63))
}
Connection.prototype.sendCopyFail = function (msg) {
// this.stream.write(this.writer.add(emptyBuffer).flush(0x66));
this.writer.addCString(msg)
this._send(0x66)
}
var Message = function (name, length) {
this.name = name
this.length = length
}
Connection.prototype.parseMessage = function (buffer) {
this.offset = 0
var length = buffer.length + 4
switch (this._reader.header) {
case 0x52: // R
return this.parseR(buffer, length)
case 0x53: // S
return this.parseS(buffer, length)
case 0x4b: // K
return this.parseK(buffer, length)
case 0x43: // C
return this.parseC(buffer, length)
case 0x5a: // Z
return this.parseZ(buffer, length)
case 0x54: // T
return this.parseT(buffer, length)
case 0x44: // D
return this.parseD(buffer, length)
case 0x45: // E
return this.parseE(buffer, length)
case 0x4e: // N
return this.parseN(buffer, length)
case 0x31: // 1
return new Message('parseComplete', length)
case 0x32: // 2
return new Message('bindComplete', length)
case 0x33: // 3
return new Message('closeComplete', length)
case 0x41: // A
return this.parseA(buffer, length)
case 0x6e: // n
return new Message('noData', length)
case 0x49: // I
return new Message('emptyQuery', length)
case 0x73: // s
return new Message('portalSuspended', length)
case 0x47: // G
return this.parseG(buffer, length)
case 0x48: // H
return this.parseH(buffer, length)
case 0x57: // W
return new Message('replicationStart', length)
case 0x63: // c
return new Message('copyDone', length)
case 0x64: // d
return this.parsed(buffer, length)
}
}
Connection.prototype.parseR = function (buffer, length) {
var code = 0
var msg = new Message('authenticationOk', length)
if (msg.length === 8) {
code = this.parseInt32(buffer)
if (code === 3) {
msg.name = 'authenticationCleartextPassword'
}
return msg
}
if (msg.length === 12) {
code = this.parseInt32(buffer)
if (code === 5) { // md5 required
msg.name = 'authenticationMD5Password'
msg.salt = Buffer.alloc(4)
buffer.copy(msg.salt, 0, this.offset, this.offset + 4)
this.offset += 4
return msg
}
}
throw new Error('Unknown authenticationOk message type' + util.inspect(msg))
}
Connection.prototype.parseS = function (buffer, length) {
var msg = new Message('parameterStatus', length)
msg.parameterName = this.parseCString(buffer)
msg.parameterValue = this.parseCString(buffer)
return msg
}
Connection.prototype.parseK = function (buffer, length) {
var msg = new Message('backendKeyData', length)
msg.processID = this.parseInt32(buffer)
msg.secretKey = this.parseInt32(buffer)
return msg
}
Connection.prototype.parseC = function (buffer, length) {
var msg = new Message('commandComplete', length)
msg.text = this.parseCString(buffer)
return msg
}
Connection.prototype.parseZ = function (buffer, length) {
var msg = new Message('readyForQuery', length)
msg.name = 'readyForQuery'
msg.status = this.readString(buffer, 1)
return msg
}
var ROW_DESCRIPTION = 'rowDescription'
Connection.prototype.parseT = function (buffer, length) {
var msg = new Message(ROW_DESCRIPTION, length)
msg.fieldCount = this.parseInt16(buffer)
var fields = []
for (var i = 0; i < msg.fieldCount; i++) {
fields.push(this.parseField(buffer))
}
msg.fields = fields
return msg
}
var Field = function () {
this.name = null
this.tableID = null
this.columnID = null
this.dataTypeID = null
this.dataTypeSize = null
this.dataTypeModifier = null
this.format = null
}
var FORMAT_TEXT = 'text'
var FORMAT_BINARY = 'binary'
Connection.prototype.parseField = function (buffer) {
var field = new Field()
field.name = this.parseCString(buffer)
field.tableID = this.parseInt32(buffer)
field.columnID = this.parseInt16(buffer)
field.dataTypeID = this.parseInt32(buffer)
field.dataTypeSize = this.parseInt16(buffer)
field.dataTypeModifier = this.parseInt32(buffer)
if (this.parseInt16(buffer) === TEXT_MODE) {
this._mode = TEXT_MODE
field.format = FORMAT_TEXT
} else {
this._mode = BINARY_MODE
field.format = FORMAT_BINARY
}
return field
}
var DATA_ROW = 'dataRow'
var DataRowMessage = function (length, fieldCount) {
this.name = DATA_ROW
this.length = length
this.fieldCount = fieldCount
this.fields = []
}
// extremely hot-path code
Connection.prototype.parseD = function (buffer, length) {
var fieldCount = this.parseInt16(buffer)
var msg = new DataRowMessage(length, fieldCount)
for (var i = 0; i < fieldCount; i++) {
msg.fields.push(this._readValue(buffer))
}
return msg
}
// extremely hot-path code
Connection.prototype._readValue = function (buffer) {
var length = this.parseInt32(buffer)
if (length === -1) return null
if (this._mode === TEXT_MODE) {
return this.readString(buffer, length)
}
return this.readBytes(buffer, length)
}
// parses error
Connection.prototype.parseE = function (buffer, length) {
var fields = {}
var msg, item
var input = new Message('error', length)
var fieldType = this.readString(buffer, 1)
while (fieldType !== '\0') {
fields[fieldType] = this.parseCString(buffer)
fieldType = this.readString(buffer, 1)
}
if (input.name === 'error') {
// the msg is an Error instance
msg = new Error(fields.M)
for (item in input) {
// copy input properties to the error
if (input.hasOwnProperty(item)) {
msg[item] = input[item]
}
}
} else {
// the msg is an object literal
msg = input
msg.message = fields.M
}
msg.severity = fields.S
msg.code = fields.C
msg.detail = fields.D
msg.hint = fields.H
msg.position = fields.P
msg.internalPosition = fields.p
msg.internalQuery = fields.q
msg.where = fields.W
msg.schema = fields.s
msg.table = fields.t
msg.column = fields.c
msg.dataType = fields.d
msg.constraint = fields.n
msg.file = fields.F
msg.line = fields.L
msg.routine = fields.R
return msg
}
// same thing, different name
Connection.prototype.parseN = function (buffer, length) {
var msg = this.parseE(buffer, length)
msg.name = 'notice'
return msg
}
Connection.prototype.parseA = function (buffer, length) {
var msg = new Message('notification', length)
msg.processId = this.parseInt32(buffer)
msg.channel = this.parseCString(buffer)
msg.payload = this.parseCString(buffer)
return msg
}
Connection.prototype.parseG = function (buffer, length) {
var msg = new Message('copyInResponse', length)
return this.parseGH(buffer, msg)
}
Connection.prototype.parseH = function (buffer, length) {
var msg = new Message('copyOutResponse', length)
return this.parseGH(buffer, msg)
}
Connection.prototype.parseGH = function (buffer, msg) {
var isBinary = buffer[this.offset] !== 0
this.offset++
msg.binary = isBinary
var columnCount = this.parseInt16(buffer)
msg.columnTypes = []
for (var i = 0; i < columnCount; i++) {
msg.columnTypes.push(this.parseInt16(buffer))
}
return msg
}
Connection.prototype.parsed = function (buffer, length) {
var msg = new Message('copyData', length)
msg.chunk = this.readBytes(buffer, msg.length - 4)
return msg
}
Connection.prototype.parseInt32 = function (buffer) {
var value = buffer.readInt32BE(this.offset)
this.offset += 4
return value
}
Connection.prototype.parseInt16 = function (buffer) {
var value = buffer.readInt16BE(this.offset)
this.offset += 2
return value
}
Connection.prototype.readString = function (buffer, length) {
return buffer.toString(this.encoding, this.offset, (this.offset += length))
}
Connection.prototype.readBytes = function (buffer, length) {
return buffer.slice(this.offset, (this.offset += length))
}
Connection.prototype.parseCString = function (buffer) {
var start = this.offset
var end = buffer.indexOf(0, start)
this.offset = end + 1
return buffer.toString(this.encoding, start, end)
}
// end parsing methods
module.exports = Connection

70
express-server/node_modules/pg/lib/defaults.js generated vendored Normal file
View File

@ -0,0 +1,70 @@
'use strict'
/**
* Copyright (c) 2010-2017 Brian Carlson (brian.m.carlson@gmail.com)
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* README.md file in the root directory of this source tree.
*/
module.exports = {
// database host. defaults to localhost
host: 'localhost',
// database user's name
user: process.platform === 'win32' ? process.env.USERNAME : process.env.USER,
// name of database to connect
database: process.platform === 'win32' ? process.env.USERNAME : process.env.USER,
// database user's password
password: null,
// a Postgres connection string to be used instead of setting individual connection items
// NOTE: Setting this value will cause it to override any other value (such as database or user) defined
// in the defaults object.
connectionString: undefined,
// database port
port: 5432,
// number of rows to return at a time from a prepared statement's
// portal. 0 will return all rows at once
rows: 0,
// binary result mode
binary: false,
// Connection pool options - see https://github.com/brianc/node-pg-pool
// number of connections to use in connection pool
// 0 will disable connection pooling
max: 10,
// max milliseconds a client can go unused before it is removed
// from the pool and destroyed
idleTimeoutMillis: 30000,
client_encoding: '',
ssl: false,
application_name: undefined,
fallback_application_name: undefined,
parseInputDatesAsUTC: false,
// max milliseconds any query using this connection will execute for before timing out in error. false=unlimited
statement_timeout: false
}
var pgTypes = require('pg-types')
// save default parsers
var parseBigInteger = pgTypes.getTypeParser(20, 'text')
var parseBigIntegerArray = pgTypes.getTypeParser(1016, 'text')
// parse int8 so you can get your count values as actual numbers
module.exports.__defineSetter__('parseInt8', function (val) {
pgTypes.setTypeParser(20, 'text', val ? pgTypes.getTypeParser(23, 'text') : parseBigInteger)
pgTypes.setTypeParser(1016, 'text', val ? pgTypes.getTypeParser(1007, 'text') : parseBigIntegerArray)
})

57
express-server/node_modules/pg/lib/index.js generated vendored Normal file
View File

@ -0,0 +1,57 @@
'use strict'
/**
* Copyright (c) 2010-2017 Brian Carlson (brian.m.carlson@gmail.com)
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* README.md file in the root directory of this source tree.
*/
var util = require('util')
var Client = require('./client')
var defaults = require('./defaults')
var Connection = require('./connection')
var Pool = require('pg-pool')
const poolFactory = (Client) => {
var BoundPool = function (options) {
var config = Object.assign({ Client: Client }, options)
return new Pool(config)
}
util.inherits(BoundPool, Pool)
return BoundPool
}
var PG = function (clientConstructor) {
this.defaults = defaults
this.Client = clientConstructor
this.Query = this.Client.Query
this.Pool = poolFactory(this.Client)
this._pools = []
this.Connection = Connection
this.types = require('pg-types')
}
if (typeof process.env.NODE_PG_FORCE_NATIVE !== 'undefined') {
module.exports = new PG(require('./native'))
} else {
module.exports = new PG(Client)
// lazy require native module...the native module may not have installed
module.exports.__defineGetter__('native', function () {
delete module.exports.native
var native = null
try {
native = new PG(require('./native'))
} catch (err) {
if (err.code !== 'MODULE_NOT_FOUND') {
throw err
}
console.error(err.message)
}
module.exports.native = native
return native
})
}

256
express-server/node_modules/pg/lib/native/client.js generated vendored Normal file
View File

@ -0,0 +1,256 @@
'use strict'
/**
* Copyright (c) 2010-2017 Brian Carlson (brian.m.carlson@gmail.com)
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* README.md file in the root directory of this source tree.
*/
var Native = require('pg-native')
var TypeOverrides = require('../type-overrides')
var semver = require('semver')
var pkg = require('../../package.json')
var assert = require('assert')
var EventEmitter = require('events').EventEmitter
var util = require('util')
var ConnectionParameters = require('../connection-parameters')
var msg = 'Version >= ' + pkg.minNativeVersion + ' of pg-native required.'
assert(semver.gte(Native.version, pkg.minNativeVersion), msg)
var NativeQuery = require('./query')
var Client = module.exports = function (config) {
EventEmitter.call(this)
config = config || {}
this._Promise = config.Promise || global.Promise
this._types = new TypeOverrides(config.types)
this.native = new Native({
types: this._types
})
this._queryQueue = []
this._ending = false
this._connecting = false
this._connected = false
this._queryable = true
// keep these on the object for legacy reasons
// for the time being. TODO: deprecate all this jazz
var cp = this.connectionParameters = new ConnectionParameters(config)
this.user = cp.user
this.password = cp.password
this.database = cp.database
this.host = cp.host
this.port = cp.port
// a hash to hold named queries
this.namedQueries = {}
}
Client.Query = NativeQuery
util.inherits(Client, EventEmitter)
Client.prototype._errorAllQueries = function (err) {
const enqueueError = (query) => {
process.nextTick(() => {
query.native = this.native
query.handleError(err)
})
}
if (this._hasActiveQuery()) {
enqueueError(this._activeQuery)
this._activeQuery = null
}
this._queryQueue.forEach(enqueueError)
this._queryQueue.length = 0
}
// connect to the backend
// pass an optional callback to be called once connected
// or with an error if there was a connection error
Client.prototype._connect = function (cb) {
var self = this
if (this._connecting) {
process.nextTick(() => cb(new Error('Client has already been connected. You cannot reuse a client.')))
return
}
this._connecting = true
this.connectionParameters.getLibpqConnectionString(function (err, conString) {
if (err) return cb(err)
self.native.connect(conString, function (err) {
if (err) return cb(err)
// set internal states to connected
self._connected = true
// handle connection errors from the native layer
self.native.on('error', function (err) {
self._queryable = false
self._errorAllQueries(err)
self.emit('error', err)
})
self.native.on('notification', function (msg) {
self.emit('notification', {
channel: msg.relname,
payload: msg.extra
})
})
// signal we are connected now
self.emit('connect')
self._pulseQueryQueue(true)
cb()
})
})
}
Client.prototype.connect = function (callback) {
if (callback) {
this._connect(callback)
return
}
return new this._Promise((resolve, reject) => {
this._connect((error) => {
if (error) {
reject(error)
} else {
resolve()
}
})
})
}
// send a query to the server
// this method is highly overloaded to take
// 1) string query, optional array of parameters, optional function callback
// 2) object query with {
// string query
// optional array values,
// optional function callback instead of as a separate parameter
// optional string name to name & cache the query plan
// optional string rowMode = 'array' for an array of results
// }
Client.prototype.query = function (config, values, callback) {
var query
var result
if (typeof config.submit === 'function') {
result = query = config
// accept query(new Query(...), (err, res) => { }) style
if (typeof values === 'function') {
config.callback = values
}
} else {
query = new NativeQuery(config, values, callback)
if (!query.callback) {
let resolveOut, rejectOut
result = new this._Promise((resolve, reject) => {
resolveOut = resolve
rejectOut = reject
})
query.callback = (err, res) => err ? rejectOut(err) : resolveOut(res)
}
}
if (!this._queryable) {
query.native = this.native
process.nextTick(() => {
query.handleError(new Error('Client has encountered a connection error and is not queryable'))
})
return result
}
if (this._ending) {
query.native = this.native
process.nextTick(() => {
query.handleError(new Error('Client was closed and is not queryable'))
})
return result
}
this._queryQueue.push(query)
this._pulseQueryQueue()
return result
}
// disconnect from the backend server
Client.prototype.end = function (cb) {
var self = this
this._ending = true
if (!this._connected) {
this.once('connect', this.end.bind(this, cb))
}
var result
if (!cb) {
result = new this._Promise(function (resolve, reject) {
cb = (err) => err ? reject(err) : resolve()
})
}
this.native.end(function () {
self._errorAllQueries(new Error('Connection terminated'))
process.nextTick(() => {
self.emit('end')
if (cb) cb()
})
})
return result
}
Client.prototype._hasActiveQuery = function () {
return this._activeQuery && this._activeQuery.state !== 'error' && this._activeQuery.state !== 'end'
}
Client.prototype._pulseQueryQueue = function (initialConnection) {
if (!this._connected) {
return
}
if (this._hasActiveQuery()) {
return
}
var query = this._queryQueue.shift()
if (!query) {
if (!initialConnection) {
this.emit('drain')
}
return
}
this._activeQuery = query
query.submit(this)
var self = this
query.once('_done', function () {
self._pulseQueryQueue()
})
}
// attempt to cancel an in-progress query
Client.prototype.cancel = function (query) {
if (this._activeQuery === query) {
this.native.cancel(function () {})
} else if (this._queryQueue.indexOf(query) !== -1) {
this._queryQueue.splice(this._queryQueue.indexOf(query), 1)
}
}
Client.prototype.setTypeParser = function (oid, format, parseFn) {
return this._types.setTypeParser(oid, format, parseFn)
}
Client.prototype.getTypeParser = function (oid, format) {
return this._types.getTypeParser(oid, format)
}

2
express-server/node_modules/pg/lib/native/index.js generated vendored Normal file
View File

@ -0,0 +1,2 @@
'use strict'
module.exports = require('./client')

160
express-server/node_modules/pg/lib/native/query.js generated vendored Normal file
View File

@ -0,0 +1,160 @@
'use strict'
/**
* Copyright (c) 2010-2017 Brian Carlson (brian.m.carlson@gmail.com)
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* README.md file in the root directory of this source tree.
*/
var EventEmitter = require('events').EventEmitter
var util = require('util')
var utils = require('../utils')
var NativeQuery = module.exports = function (config, values, callback) {
EventEmitter.call(this)
config = utils.normalizeQueryConfig(config, values, callback)
this.text = config.text
this.values = config.values
this.name = config.name
this.callback = config.callback
this.state = 'new'
this._arrayMode = config.rowMode === 'array'
// if the 'row' event is listened for
// then emit them as they come in
// without setting singleRowMode to true
// this has almost no meaning because libpq
// reads all rows into memory befor returning any
this._emitRowEvents = false
this.on('newListener', function (event) {
if (event === 'row') this._emitRowEvents = true
}.bind(this))
}
util.inherits(NativeQuery, EventEmitter)
var errorFieldMap = {
'sqlState': 'code',
'statementPosition': 'position',
'messagePrimary': 'message',
'context': 'where',
'schemaName': 'schema',
'tableName': 'table',
'columnName': 'column',
'dataTypeName': 'dataType',
'constraintName': 'constraint',
'sourceFile': 'file',
'sourceLine': 'line',
'sourceFunction': 'routine'
}
NativeQuery.prototype.handleError = function (err) {
// copy pq error fields into the error object
var fields = this.native.pq.resultErrorFields()
if (fields) {
for (var key in fields) {
var normalizedFieldName = errorFieldMap[key] || key
err[normalizedFieldName] = fields[key]
}
}
if (this.callback) {
this.callback(err)
} else {
this.emit('error', err)
}
this.state = 'error'
}
NativeQuery.prototype.then = function (onSuccess, onFailure) {
return this._getPromise().then(onSuccess, onFailure)
}
NativeQuery.prototype.catch = function (callback) {
return this._getPromise().catch(callback)
}
NativeQuery.prototype._getPromise = function () {
if (this._promise) return this._promise
this._promise = new Promise(function (resolve, reject) {
this._once('end', resolve)
this._once('error', reject)
}.bind(this))
return this._promise
}
NativeQuery.prototype.submit = function (client) {
this.state = 'running'
var self = this
this.native = client.native
client.native.arrayMode = this._arrayMode
var after = function (err, rows, results) {
client.native.arrayMode = false
setImmediate(function () {
self.emit('_done')
})
// handle possible query error
if (err) {
return self.handleError(err)
}
// emit row events for each row in the result
if (self._emitRowEvents) {
if (results.length > 1) {
rows.forEach((rowOfRows, i) => {
rowOfRows.forEach(row => {
self.emit('row', row, results[i])
})
})
} else {
rows.forEach(function (row) {
self.emit('row', row, results)
})
}
}
// handle successful result
self.state = 'end'
self.emit('end', results)
if (self.callback) {
self.callback(null, results)
}
}
if (process.domain) {
after = process.domain.bind(after)
}
// named query
if (this.name) {
if (this.name.length > 63) {
console.error('Warning! Postgres only supports 63 characters for query names.')
console.error('You supplied', this.name, '(', this.name.length, ')')
console.error('This can cause conflicts and silent errors executing queries')
}
var values = (this.values || []).map(utils.prepareValue)
// check if the client has already executed this named query
// if so...just execute it again - skip the planning phase
if (client.namedQueries[this.name]) {
return client.native.execute(this.name, values, after)
}
// plan the named query the first time, then execute it
return client.native.prepare(this.name, this.text, values.length, function (err) {
if (err) return after(err)
client.namedQueries[self.name] = true
return self.native.execute(self.name, values, after)
})
} else if (this.values) {
if (!Array.isArray(this.values)) {
const err = new Error('Query values must be an array')
return after(err)
}
var vals = this.values.map(utils.prepareValue)
client.native.query(this.text, vals, after)
} else {
client.native.query(this.text, after)
}
}

219
express-server/node_modules/pg/lib/query.js generated vendored Normal file
View File

@ -0,0 +1,219 @@
'use strict'
/**
* Copyright (c) 2010-2017 Brian Carlson (brian.m.carlson@gmail.com)
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* README.md file in the root directory of this source tree.
*/
var EventEmitter = require('events').EventEmitter
var util = require('util')
var Result = require('./result')
var utils = require('./utils')
var Query = function (config, values, callback) {
// use of "new" optional
if (!(this instanceof Query)) { return new Query(config, values, callback) }
config = utils.normalizeQueryConfig(config, values, callback)
this.text = config.text
this.values = config.values
this.rows = config.rows
this.types = config.types
this.name = config.name
this.binary = config.binary
// use unique portal name each time
this.portal = config.portal || ''
this.callback = config.callback
this._rowMode = config.rowMode
if (process.domain && config.callback) {
this.callback = process.domain.bind(config.callback)
}
this._result = new Result(this._rowMode, this.types)
// potential for multiple results
this._results = this._result
this.isPreparedStatement = false
this._canceledDueToError = false
this._promise = null
EventEmitter.call(this)
}
util.inherits(Query, EventEmitter)
Query.prototype.requiresPreparation = function () {
// named queries must always be prepared
if (this.name) { return true }
// always prepare if there are max number of rows expected per
// portal execution
if (this.rows) { return true }
// don't prepare empty text queries
if (!this.text) { return false }
// prepare if there are values
if (!this.values) { return false }
return this.values.length > 0
}
Query.prototype._checkForMultirow = function () {
// if we already have a result with a command property
// then we've already executed one query in a multi-statement simple query
// turn our results into an array of results
if (this._result.command) {
if (!Array.isArray(this._results)) {
this._results = [this._result]
}
this._result = new Result(this._rowMode, this.types)
this._results.push(this._result)
}
}
// associates row metadata from the supplied
// message with this query object
// metadata used when parsing row results
Query.prototype.handleRowDescription = function (msg) {
this._checkForMultirow()
this._result.addFields(msg.fields)
this._accumulateRows = this.callback || !this.listeners('row').length
}
Query.prototype.handleDataRow = function (msg) {
var row
if (this._canceledDueToError) {
return
}
try {
row = this._result.parseRow(msg.fields)
} catch (err) {
this._canceledDueToError = err
return
}
this.emit('row', row, this._result)
if (this._accumulateRows) {
this._result.addRow(row)
}
}
Query.prototype.handleCommandComplete = function (msg, con) {
this._checkForMultirow()
this._result.addCommandComplete(msg)
// need to sync after each command complete of a prepared statement
if (this.isPreparedStatement) {
con.sync()
}
}
// if a named prepared statement is created with empty query text
// the backend will send an emptyQuery message but *not* a command complete message
// execution on the connection will hang until the backend receives a sync message
Query.prototype.handleEmptyQuery = function (con) {
if (this.isPreparedStatement) {
con.sync()
}
}
Query.prototype.handleReadyForQuery = function (con) {
if (this._canceledDueToError) {
return this.handleError(this._canceledDueToError, con)
}
if (this.callback) {
this.callback(null, this._results)
}
this.emit('end', this._results)
}
Query.prototype.handleError = function (err, connection) {
// need to sync after error during a prepared statement
if (this.isPreparedStatement) {
connection.sync()
}
if (this._canceledDueToError) {
err = this._canceledDueToError
this._canceledDueToError = false
}
// if callback supplied do not emit error event as uncaught error
// events will bubble up to node process
if (this.callback) {
return this.callback(err)
}
this.emit('error', err)
}
Query.prototype.submit = function (connection) {
if (typeof this.text !== 'string' && typeof this.name !== 'string') {
return new Error('A query must have either text or a name. Supplying neither is unsupported.')
}
if (this.values && !Array.isArray(this.values)) {
return new Error('Query values must be an array')
}
if (this.requiresPreparation()) {
this.prepare(connection)
} else {
connection.query(this.text)
}
return null
}
Query.prototype.hasBeenParsed = function (connection) {
return this.name && connection.parsedStatements[this.name]
}
Query.prototype.handlePortalSuspended = function (connection) {
this._getRows(connection, this.rows)
}
Query.prototype._getRows = function (connection, rows) {
connection.execute({
portal: this.portal,
rows: rows
}, true)
connection.flush()
}
Query.prototype.prepare = function (connection) {
var self = this
// prepared statements need sync to be called after each command
// complete or when an error is encountered
this.isPreparedStatement = true
// TODO refactor this poor encapsulation
if (!this.hasBeenParsed(connection)) {
connection.parse({
text: self.text,
name: self.name,
types: self.types
}, true)
}
if (self.values) {
self.values = self.values.map(utils.prepareValue)
}
// http://developer.postgresql.org/pgdocs/postgres/protocol-flow.html#PROTOCOL-FLOW-EXT-QUERY
connection.bind({
portal: self.portal,
statement: self.name,
values: self.values,
binary: self.binary
}, true)
connection.describe({
type: 'P',
name: self.portal || ''
}, true)
this._getRows(connection, this.rows)
}
Query.prototype.handleCopyInResponse = function (connection) {
connection.sendCopyFail('No source stream defined')
}
Query.prototype.handleCopyData = function (msg, connection) {
// noop
}
module.exports = Query

104
express-server/node_modules/pg/lib/result.js generated vendored Normal file
View File

@ -0,0 +1,104 @@
'use strict'
/**
* Copyright (c) 2010-2017 Brian Carlson (brian.m.carlson@gmail.com)
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* README.md file in the root directory of this source tree.
*/
var types = require('pg-types')
// result object returned from query
// in the 'end' event and also
// passed as second argument to provided callback
var Result = function (rowMode) {
this.command = null
this.rowCount = null
this.oid = null
this.rows = []
this.fields = []
this._parsers = []
this.RowCtor = null
this.rowAsArray = rowMode === 'array'
if (this.rowAsArray) {
this.parseRow = this._parseRowAsArray
}
}
var matchRegexp = /^([A-Za-z]+)(?: (\d+))?(?: (\d+))?/
// adds a command complete message
Result.prototype.addCommandComplete = function (msg) {
var match
if (msg.text) {
// pure javascript
match = matchRegexp.exec(msg.text)
} else {
// native bindings
match = matchRegexp.exec(msg.command)
}
if (match) {
this.command = match[1]
if (match[3]) {
// COMMMAND OID ROWS
this.oid = parseInt(match[2], 10)
this.rowCount = parseInt(match[3], 10)
} else if (match[2]) {
// COMMAND ROWS
this.rowCount = parseInt(match[2], 10)
}
}
}
Result.prototype._parseRowAsArray = function (rowData) {
var row = []
for (var i = 0, len = rowData.length; i < len; i++) {
var rawValue = rowData[i]
if (rawValue !== null) {
row.push(this._parsers[i](rawValue))
} else {
row.push(null)
}
}
return row
}
Result.prototype.parseRow = function (rowData) {
var row = {}
for (var i = 0, len = rowData.length; i < len; i++) {
var rawValue = rowData[i]
var field = this.fields[i].name
if (rawValue !== null) {
row[field] = this._parsers[i](rawValue)
} else {
row[field] = null
}
}
return row
}
Result.prototype.addRow = function (row) {
this.rows.push(row)
}
Result.prototype.addFields = function (fieldDescriptions) {
// clears field definitions
// multiple query statements in 1 action can result in multiple sets
// of rowDescriptions...eg: 'select NOW(); select 1::int;'
// you need to reset the fields
if (this.fields.length) {
this.fields = []
this._parsers = []
}
for (var i = 0; i < fieldDescriptions.length; i++) {
var desc = fieldDescriptions[i]
this.fields.push(desc)
var parser = this._getTypeParser(desc.dataTypeID, desc.format || 'text')
this._parsers.push(parser)
}
}
Result.prototype._getTypeParser = types.getTypeParser
module.exports = Result

39
express-server/node_modules/pg/lib/type-overrides.js generated vendored Normal file
View File

@ -0,0 +1,39 @@
'use strict'
/**
* Copyright (c) 2010-2017 Brian Carlson (brian.m.carlson@gmail.com)
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* README.md file in the root directory of this source tree.
*/
var types = require('pg-types')
function TypeOverrides (userTypes) {
this._types = userTypes || types
this.text = {}
this.binary = {}
}
TypeOverrides.prototype.getOverrides = function (format) {
switch (format) {
case 'text': return this.text
case 'binary': return this.binary
default: return {}
}
}
TypeOverrides.prototype.setTypeParser = function (oid, format, parseFn) {
if (typeof format === 'function') {
parseFn = format
format = 'text'
}
this.getOverrides(format)[oid] = parseFn
}
TypeOverrides.prototype.getTypeParser = function (oid, format) {
format = format || 'text'
return this.getOverrides(format)[oid] || this._types.getTypeParser(oid, format)
}
module.exports = TypeOverrides

164
express-server/node_modules/pg/lib/utils.js generated vendored Normal file
View File

@ -0,0 +1,164 @@
'use strict'
/**
* Copyright (c) 2010-2017 Brian Carlson (brian.m.carlson@gmail.com)
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* README.md file in the root directory of this source tree.
*/
const crypto = require('crypto')
const defaults = require('./defaults')
function escapeElement (elementRepresentation) {
var escaped = elementRepresentation
.replace(/\\/g, '\\\\')
.replace(/"/g, '\\"')
return '"' + escaped + '"'
}
// convert a JS array to a postgres array literal
// uses comma separator so won't work for types like box that use
// a different array separator.
function arrayString (val) {
var result = '{'
for (var i = 0; i < val.length; i++) {
if (i > 0) {
result = result + ','
}
if (val[i] === null || typeof val[i] === 'undefined') {
result = result + 'NULL'
} else if (Array.isArray(val[i])) {
result = result + arrayString(val[i])
} else if (val[i] instanceof Buffer) {
result += '\\\\x' + val[i].toString('hex')
} else {
result += escapeElement(prepareValue(val[i]))
}
}
result = result + '}'
return result
}
// converts values from javascript types
// to their 'raw' counterparts for use as a postgres parameter
// note: you can override this function to provide your own conversion mechanism
// for complex types, etc...
var prepareValue = function (val, seen) {
if (val instanceof Buffer) {
return val
}
if (ArrayBuffer.isView(val)) {
var buf = Buffer.from(val.buffer, val.byteOffset, val.byteLength)
if (buf.length === val.byteLength) {
return buf
}
return buf.slice(val.byteOffset, val.byteOffset + val.byteLength) // Node.js v4 does not support those Buffer.from params
}
if (val instanceof Date) {
if (defaults.parseInputDatesAsUTC) {
return dateToStringUTC(val)
} else {
return dateToString(val)
}
}
if (Array.isArray(val)) {
return arrayString(val)
}
if (val === null || typeof val === 'undefined') {
return null
}
if (typeof val === 'object') {
return prepareObject(val, seen)
}
return val.toString()
}
function prepareObject (val, seen) {
if (val && typeof val.toPostgres === 'function') {
seen = seen || []
if (seen.indexOf(val) !== -1) {
throw new Error('circular reference detected while preparing "' + val + '" for query')
}
seen.push(val)
return prepareValue(val.toPostgres(prepareValue), seen)
}
return JSON.stringify(val)
}
function pad (number, digits) {
number = '' + number
while (number.length < digits) { number = '0' + number }
return number
}
function dateToString (date) {
var offset = -date.getTimezoneOffset()
var ret = pad(date.getFullYear(), 4) + '-' +
pad(date.getMonth() + 1, 2) + '-' +
pad(date.getDate(), 2) + 'T' +
pad(date.getHours(), 2) + ':' +
pad(date.getMinutes(), 2) + ':' +
pad(date.getSeconds(), 2) + '.' +
pad(date.getMilliseconds(), 3)
if (offset < 0) {
ret += '-'
offset *= -1
} else { ret += '+' }
return ret + pad(Math.floor(offset / 60), 2) + ':' + pad(offset % 60, 2)
}
function dateToStringUTC (date) {
var ret = pad(date.getUTCFullYear(), 4) + '-' +
pad(date.getUTCMonth() + 1, 2) + '-' +
pad(date.getUTCDate(), 2) + 'T' +
pad(date.getUTCHours(), 2) + ':' +
pad(date.getUTCMinutes(), 2) + ':' +
pad(date.getUTCSeconds(), 2) + '.' +
pad(date.getUTCMilliseconds(), 3)
return ret + '+00:00'
}
function normalizeQueryConfig (config, values, callback) {
// can take in strings or config objects
config = (typeof (config) === 'string') ? { text: config } : config
if (values) {
if (typeof values === 'function') {
config.callback = values
} else {
config.values = values
}
}
if (callback) {
config.callback = callback
}
return config
}
const md5 = function (string) {
return crypto.createHash('md5').update(string, 'utf-8').digest('hex')
}
// See AuthenticationMD5Password at https://www.postgresql.org/docs/current/static/protocol-flow.html
const postgresMd5PasswordHash = function (user, password, salt) {
var inner = md5(password + user)
var outer = md5(Buffer.concat([Buffer.from(inner), salt]))
return 'md5' + outer
}
module.exports = {
prepareValue: function prepareValueWrapper (value) {
// this ensures that extra arguments do not get passed into prepareValue
// by accident, eg: from calling values.map(utils.prepareValue)
return prepareValue(value)
},
normalizeQueryConfig,
postgresMd5PasswordHash,
md5
}

View File

@ -0,0 +1,15 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
"$basedir/node" "$basedir/../semver/bin/semver" "$@"
ret=$?
else
node "$basedir/../semver/bin/semver" "$@"
ret=$?
fi
exit $ret

View File

@ -0,0 +1,7 @@
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" "%~dp0\..\semver\bin\semver" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node "%~dp0\..\semver\bin\semver" %*
)

View File

@ -0,0 +1 @@
# nada

View File

@ -0,0 +1,27 @@
Copyright (c) Isaac Z. Schlueter ("Author")
All rights reserved.
The BSD License
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -0,0 +1,24 @@
files = semver.browser.js \
semver.min.js \
semver.browser.js.gz \
semver.min.js.gz
all: $(files)
clean:
rm -f $(files)
semver.browser.js: head.js.txt semver.js foot.js.txt
( cat head.js.txt; \
cat semver.js | \
egrep -v '^ *\/\* nomin \*\/' | \
perl -pi -e 's/debug\([^\)]+\)//g'; \
cat foot.js.txt ) > semver.browser.js
semver.min.js: semver.browser.js
uglifyjs -m <semver.browser.js >semver.min.js
%.gz: %
gzip --stdout -9 <$< >$@
.PHONY: all clean

View File

@ -0,0 +1,303 @@
semver(1) -- The semantic versioner for npm
===========================================
## Usage
$ npm install semver
semver.valid('1.2.3') // '1.2.3'
semver.valid('a.b.c') // null
semver.clean(' =v1.2.3 ') // '1.2.3'
semver.satisfies('1.2.3', '1.x || >=2.5.0 || 5.0.0 - 7.2.3') // true
semver.gt('1.2.3', '9.8.7') // false
semver.lt('1.2.3', '9.8.7') // true
As a command-line utility:
$ semver -h
Usage: semver <version> [<version> [...]] [-r <range> | -i <inc> | --preid <identifier> | -l | -rv]
Test if version(s) satisfy the supplied range(s), and sort them.
Multiple versions or ranges may be supplied, unless increment
option is specified. In that case, only a single version may
be used, and it is incremented by the specified level
Program exits successfully if any valid version satisfies
all supplied ranges, and prints all satisfying versions.
If no versions are valid, or ranges are not satisfied,
then exits failure.
Versions are printed in ascending order, so supplying
multiple versions to the utility will just sort them.
## Versions
A "version" is described by the `v2.0.0` specification found at
<http://semver.org/>.
A leading `"="` or `"v"` character is stripped off and ignored.
## Ranges
A `version range` is a set of `comparators` which specify versions
that satisfy the range.
A `comparator` is composed of an `operator` and a `version`. The set
of primitive `operators` is:
* `<` Less than
* `<=` Less than or equal to
* `>` Greater than
* `>=` Greater than or equal to
* `=` Equal. If no operator is specified, then equality is assumed,
so this operator is optional, but MAY be included.
For example, the comparator `>=1.2.7` would match the versions
`1.2.7`, `1.2.8`, `2.5.3`, and `1.3.9`, but not the versions `1.2.6`
or `1.1.0`.
Comparators can be joined by whitespace to form a `comparator set`,
which is satisfied by the **intersection** of all of the comparators
it includes.
A range is composed of one or more comparator sets, joined by `||`. A
version matches a range if and only if every comparator in at least
one of the `||`-separated comparator sets is satisfied by the version.
For example, the range `>=1.2.7 <1.3.0` would match the versions
`1.2.7`, `1.2.8`, and `1.2.99`, but not the versions `1.2.6`, `1.3.0`,
or `1.1.0`.
The range `1.2.7 || >=1.2.9 <2.0.0` would match the versions `1.2.7`,
`1.2.9`, and `1.4.6`, but not the versions `1.2.8` or `2.0.0`.
### Prerelease Tags
If a version has a prerelease tag (for example, `1.2.3-alpha.3`) then
it will only be allowed to satisfy comparator sets if at least one
comparator with the same `[major, minor, patch]` tuple also has a
prerelease tag.
For example, the range `>1.2.3-alpha.3` would be allowed to match the
version `1.2.3-alpha.7`, but it would *not* be satisfied by
`3.4.5-alpha.9`, even though `3.4.5-alpha.9` is technically "greater
than" `1.2.3-alpha.3` according to the SemVer sort rules. The version
range only accepts prerelease tags on the `1.2.3` version. The
version `3.4.5` *would* satisfy the range, because it does not have a
prerelease flag, and `3.4.5` is greater than `1.2.3-alpha.7`.
The purpose for this behavior is twofold. First, prerelease versions
frequently are updated very quickly, and contain many breaking changes
that are (by the author's design) not yet fit for public consumption.
Therefore, by default, they are excluded from range matching
semantics.
Second, a user who has opted into using a prerelease version has
clearly indicated the intent to use *that specific* set of
alpha/beta/rc versions. By including a prerelease tag in the range,
the user is indicating that they are aware of the risk. However, it
is still not appropriate to assume that they have opted into taking a
similar risk on the *next* set of prerelease versions.
#### Prerelease Identifiers
The method `.inc` takes an additional `identifier` string argument that
will append the value of the string as a prerelease identifier:
```javascript
> semver.inc('1.2.3', 'pre', 'beta')
'1.2.4-beta.0'
```
command-line example:
```shell
$ semver 1.2.3 -i prerelease --preid beta
1.2.4-beta.0
```
Which then can be used to increment further:
```shell
$ semver 1.2.4-beta.0 -i prerelease
1.2.4-beta.1
```
### Advanced Range Syntax
Advanced range syntax desugars to primitive comparators in
deterministic ways.
Advanced ranges may be combined in the same way as primitive
comparators using white space or `||`.
#### Hyphen Ranges `X.Y.Z - A.B.C`
Specifies an inclusive set.
* `1.2.3 - 2.3.4` := `>=1.2.3 <=2.3.4`
If a partial version is provided as the first version in the inclusive
range, then the missing pieces are replaced with zeroes.
* `1.2 - 2.3.4` := `>=1.2.0 <=2.3.4`
If a partial version is provided as the second version in the
inclusive range, then all versions that start with the supplied parts
of the tuple are accepted, but nothing that would be greater than the
provided tuple parts.
* `1.2.3 - 2.3` := `>=1.2.3 <2.4.0`
* `1.2.3 - 2` := `>=1.2.3 <3.0.0`
#### X-Ranges `1.2.x` `1.X` `1.2.*` `*`
Any of `X`, `x`, or `*` may be used to "stand in" for one of the
numeric values in the `[major, minor, patch]` tuple.
* `*` := `>=0.0.0` (Any version satisfies)
* `1.x` := `>=1.0.0 <2.0.0` (Matching major version)
* `1.2.x` := `>=1.2.0 <1.3.0` (Matching major and minor versions)
A partial version range is treated as an X-Range, so the special
character is in fact optional.
* `""` (empty string) := `*` := `>=0.0.0`
* `1` := `1.x.x` := `>=1.0.0 <2.0.0`
* `1.2` := `1.2.x` := `>=1.2.0 <1.3.0`
#### Tilde Ranges `~1.2.3` `~1.2` `~1`
Allows patch-level changes if a minor version is specified on the
comparator. Allows minor-level changes if not.
* `~1.2.3` := `>=1.2.3 <1.(2+1).0` := `>=1.2.3 <1.3.0`
* `~1.2` := `>=1.2.0 <1.(2+1).0` := `>=1.2.0 <1.3.0` (Same as `1.2.x`)
* `~1` := `>=1.0.0 <(1+1).0.0` := `>=1.0.0 <2.0.0` (Same as `1.x`)
* `~0.2.3` := `>=0.2.3 <0.(2+1).0` := `>=0.2.3 <0.3.0`
* `~0.2` := `>=0.2.0 <0.(2+1).0` := `>=0.2.0 <0.3.0` (Same as `0.2.x`)
* `~0` := `>=0.0.0 <(0+1).0.0` := `>=0.0.0 <1.0.0` (Same as `0.x`)
* `~1.2.3-beta.2` := `>=1.2.3-beta.2 <1.3.0` Note that prereleases in
the `1.2.3` version will be allowed, if they are greater than or
equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but
`1.2.4-beta.2` would not, because it is a prerelease of a
different `[major, minor, patch]` tuple.
#### Caret Ranges `^1.2.3` `^0.2.5` `^0.0.4`
Allows changes that do not modify the left-most non-zero digit in the
`[major, minor, patch]` tuple. In other words, this allows patch and
minor updates for versions `1.0.0` and above, patch updates for
versions `0.X >=0.1.0`, and *no* updates for versions `0.0.X`.
Many authors treat a `0.x` version as if the `x` were the major
"breaking-change" indicator.
Caret ranges are ideal when an author may make breaking changes
between `0.2.4` and `0.3.0` releases, which is a common practice.
However, it presumes that there will *not* be breaking changes between
`0.2.4` and `0.2.5`. It allows for changes that are presumed to be
additive (but non-breaking), according to commonly observed practices.
* `^1.2.3` := `>=1.2.3 <2.0.0`
* `^0.2.3` := `>=0.2.3 <0.3.0`
* `^0.0.3` := `>=0.0.3 <0.0.4`
* `^1.2.3-beta.2` := `>=1.2.3-beta.2 <2.0.0` Note that prereleases in
the `1.2.3` version will be allowed, if they are greater than or
equal to `beta.2`. So, `1.2.3-beta.4` would be allowed, but
`1.2.4-beta.2` would not, because it is a prerelease of a
different `[major, minor, patch]` tuple.
* `^0.0.3-beta` := `>=0.0.3-beta <0.0.4` Note that prereleases in the
`0.0.3` version *only* will be allowed, if they are greater than or
equal to `beta`. So, `0.0.3-pr.2` would be allowed.
When parsing caret ranges, a missing `patch` value desugars to the
number `0`, but will allow flexibility within that value, even if the
major and minor versions are both `0`.
* `^1.2.x` := `>=1.2.0 <2.0.0`
* `^0.0.x` := `>=0.0.0 <0.1.0`
* `^0.0` := `>=0.0.0 <0.1.0`
A missing `minor` and `patch` values will desugar to zero, but also
allow flexibility within those values, even if the major version is
zero.
* `^1.x` := `>=1.0.0 <2.0.0`
* `^0.x` := `>=0.0.0 <1.0.0`
## Functions
All methods and classes take a final `loose` boolean argument that, if
true, will be more forgiving about not-quite-valid semver strings.
The resulting output will always be 100% strict, of course.
Strict-mode Comparators and Ranges will be strict about the SemVer
strings that they parse.
* `valid(v)`: Return the parsed version, or null if it's not valid.
* `inc(v, release)`: Return the version incremented by the release
type (`major`, `premajor`, `minor`, `preminor`, `patch`,
`prepatch`, or `prerelease`), or null if it's not valid
* `premajor` in one call will bump the version up to the next major
version and down to a prerelease of that major version.
`preminor`, and `prepatch` work the same way.
* If called from a non-prerelease version, the `prerelease` will work the
same as `prepatch`. It increments the patch version, then makes a
prerelease. If the input version is already a prerelease it simply
increments it.
* `major(v)`: Return the major version number.
* `minor(v)`: Return the minor version number.
* `patch(v)`: Return the patch version number.
### Comparison
* `gt(v1, v2)`: `v1 > v2`
* `gte(v1, v2)`: `v1 >= v2`
* `lt(v1, v2)`: `v1 < v2`
* `lte(v1, v2)`: `v1 <= v2`
* `eq(v1, v2)`: `v1 == v2` This is true if they're logically equivalent,
even if they're not the exact same string. You already know how to
compare strings.
* `neq(v1, v2)`: `v1 != v2` The opposite of `eq`.
* `cmp(v1, comparator, v2)`: Pass in a comparison string, and it'll call
the corresponding function above. `"==="` and `"!=="` do simple
string comparison, but are included for completeness. Throws if an
invalid comparison string is provided.
* `compare(v1, v2)`: Return `0` if `v1 == v2`, or `1` if `v1` is greater, or `-1` if
`v2` is greater. Sorts in ascending order if passed to `Array.sort()`.
* `rcompare(v1, v2)`: The reverse of compare. Sorts an array of versions
in descending order when passed to `Array.sort()`.
* `diff(v1, v2)`: Returns difference between two versions by the release type
(`major`, `premajor`, `minor`, `preminor`, `patch`, `prepatch`, or `prerelease`),
or null if the versions are the same.
### Ranges
* `validRange(range)`: Return the valid range or null if it's not valid
* `satisfies(version, range)`: Return true if the version satisfies the
range.
* `maxSatisfying(versions, range)`: Return the highest version in the list
that satisfies the range, or `null` if none of them do.
* `gtr(version, range)`: Return `true` if version is greater than all the
versions possible in the range.
* `ltr(version, range)`: Return `true` if version is less than all the
versions possible in the range.
* `outside(version, range, hilo)`: Return true if the version is outside
the bounds of the range in either the high or low direction. The
`hilo` argument must be either the string `'>'` or `'<'`. (This is
the function called by `gtr` and `ltr`.)
Note that, since ranges may be non-contiguous, a version might not be
greater than a range, less than a range, *or* satisfy a range! For
example, the range `1.2 <1.2.9 || >2.0.0` would have a hole from `1.2.9`
until `2.0.0`, so the version `1.2.10` would not be greater than the
range (because `2.0.1` satisfies, which is higher), nor less than the
range (since `1.2.8` satisfies, which is lower), and it also does not
satisfy the range.
If you want to know if a version satisfies or does not satisfy a
range, use the `satisfies(version, range)` function.

View File

@ -0,0 +1,133 @@
#!/usr/bin/env node
// Standalone semver comparison program.
// Exits successfully and prints matching version(s) if
// any supplied version is valid and passes all tests.
var argv = process.argv.slice(2)
, versions = []
, range = []
, gt = []
, lt = []
, eq = []
, inc = null
, version = require("../package.json").version
, loose = false
, identifier = undefined
, semver = require("../semver")
, reverse = false
main()
function main () {
if (!argv.length) return help()
while (argv.length) {
var a = argv.shift()
var i = a.indexOf('=')
if (i !== -1) {
a = a.slice(0, i)
argv.unshift(a.slice(i + 1))
}
switch (a) {
case "-rv": case "-rev": case "--rev": case "--reverse":
reverse = true
break
case "-l": case "--loose":
loose = true
break
case "-v": case "--version":
versions.push(argv.shift())
break
case "-i": case "--inc": case "--increment":
switch (argv[0]) {
case "major": case "minor": case "patch": case "prerelease":
case "premajor": case "preminor": case "prepatch":
inc = argv.shift()
break
default:
inc = "patch"
break
}
break
case "--preid":
identifier = argv.shift()
break
case "-r": case "--range":
range.push(argv.shift())
break
case "-h": case "--help": case "-?":
return help()
default:
versions.push(a)
break
}
}
versions = versions.filter(function (v) {
return semver.valid(v, loose)
})
if (!versions.length) return fail()
if (inc && (versions.length !== 1 || range.length))
return failInc()
for (var i = 0, l = range.length; i < l ; i ++) {
versions = versions.filter(function (v) {
return semver.satisfies(v, range[i], loose)
})
if (!versions.length) return fail()
}
return success(versions)
}
function failInc () {
console.error("--inc can only be used on a single version with no range")
fail()
}
function fail () { process.exit(1) }
function success () {
var compare = reverse ? "rcompare" : "compare"
versions.sort(function (a, b) {
return semver[compare](a, b, loose)
}).map(function (v) {
return semver.clean(v, loose)
}).map(function (v) {
return inc ? semver.inc(v, inc, loose, identifier) : v
}).forEach(function (v,i,_) { console.log(v) })
}
function help () {
console.log(["SemVer " + version
,""
,"A JavaScript implementation of the http://semver.org/ specification"
,"Copyright Isaac Z. Schlueter"
,""
,"Usage: semver [options] <version> [<version> [...]]"
,"Prints valid versions sorted by SemVer precedence"
,""
,"Options:"
,"-r --range <range>"
," Print versions that match the specified range."
,""
,"-i --increment [<level>]"
," Increment a version by the specified level. Level can"
," be one of: major, minor, patch, premajor, preminor,"
," prepatch, or prerelease. Default level is 'patch'."
," Only one version may be specified."
,""
,"--preid <identifier>"
," Identifier to be used to prefix premajor, preminor,"
," prepatch or prerelease version increments."
,""
,"-l --loose"
," Interpret versions and ranges loosely"
,""
,"Program exits successfully if any valid version satisfies"
,"all supplied ranges, and prints all satisfying versions."
,""
,"If no satisfying versions are found, then exits failure."
,""
,"Versions are printed in ascending order, so supplying"
,"multiple versions to the utility will just sort them."
].join("\n"))
}

View File

@ -0,0 +1,6 @@
})(
typeof exports === 'object' ? exports :
typeof define === 'function' && define.amd ? {} :
semver = {}
);

View File

@ -0,0 +1,2 @@
;(function(exports) {

View File

@ -0,0 +1,53 @@
{
"_from": "semver@4.3.2",
"_id": "semver@4.3.2",
"_inBundle": false,
"_integrity": "sha1-x6BxWKgL7dBSNVt3DYLWZA+AO+c=",
"_location": "/pg/semver",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "semver@4.3.2",
"name": "semver",
"escapedName": "semver",
"rawSpec": "4.3.2",
"saveSpec": null,
"fetchSpec": "4.3.2"
},
"_requiredBy": [
"/pg"
],
"_resolved": "http://registry.npmjs.org/semver/-/semver-4.3.2.tgz",
"_shasum": "c7a07158a80bedd052355b770d82d6640f803be7",
"_spec": "semver@4.3.2",
"_where": "D:\\5CHITM\\Diplomarbeit\\smart-shopper\\SmartShopper\\express-server\\node_modules\\pg",
"bin": {
"semver": "./bin/semver"
},
"browser": "semver.browser.js",
"bugs": {
"url": "https://github.com/npm/node-semver/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "The semantic version parser used by npm.",
"devDependencies": {
"tap": "0.x >=0.0.4",
"uglify-js": "~2.3.6"
},
"homepage": "https://github.com/npm/node-semver#readme",
"license": "BSD",
"main": "semver.js",
"min": "semver.min.js",
"name": "semver",
"repository": {
"type": "git",
"url": "git://github.com/npm/node-semver.git"
},
"scripts": {
"prepublish": "make",
"test": "tap test/*.js"
},
"version": "4.3.2"
}

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -0,0 +1,15 @@
var tap = require('tap');
var test = tap.test;
test('amd', function(t) {
global.define = define;
define.amd = true;
var defined = null;
function define(stuff) {
defined = stuff;
}
var fromRequire = require('../');
t.ok(defined, 'amd function called');
t.equal(fromRequire, defined, 'amd stuff same as require stuff');
t.end();
});

View File

@ -0,0 +1,24 @@
var test = require('tap').test
var semver = require('../')
test('long version is too long', function (t) {
var v = '1.2.' + new Array(256).join('1')
t.throws(function () {
new semver.SemVer(v)
})
t.equal(semver.valid(v, false), null)
t.equal(semver.valid(v, true), null)
t.equal(semver.inc(v, 'patch'), null)
t.end()
})
test('big number is like too long version', function (t) {
var v = '1.2.' + new Array(100).join('1')
t.throws(function () {
new semver.SemVer(v)
})
t.equal(semver.valid(v, false), null)
t.equal(semver.valid(v, true), null)
t.equal(semver.inc(v, 'patch'), null)
t.end()
})

View File

@ -0,0 +1,29 @@
var tap = require('tap');
var test = tap.test;
var semver = require('../semver.js');
var clean = semver.clean;
test('\nclean tests', function(t) {
// [range, version]
// Version should be detectable despite extra characters
[
['1.2.3', '1.2.3'],
[' 1.2.3 ', '1.2.3'],
[' 1.2.3-4 ', '1.2.3-4'],
[' 1.2.3-pre ', '1.2.3-pre'],
[' =v1.2.3 ', '1.2.3'],
['v1.2.3', '1.2.3'],
[' v1.2.3 ', '1.2.3'],
['\t1.2.3', '1.2.3'],
['>1.2.3', null],
['~1.2.3', null],
['<=1.2.3', null],
['1.2.x', null]
].forEach(function(tuple) {
var range = tuple[0];
var version = tuple[1];
var msg = 'clean(' + range + ') = ' + version;
t.equal(clean(range), version, msg);
});
t.end();
});

View File

@ -0,0 +1,173 @@
var tap = require('tap');
var test = tap.test;
var semver = require('../semver.js');
var gtr = semver.gtr;
test('\ngtr tests', function(t) {
// [range, version, loose]
// Version should be greater than range
[
['~1.2.2', '1.3.0'],
['~0.6.1-1', '0.7.1-1'],
['1.0.0 - 2.0.0', '2.0.1'],
['1.0.0', '1.0.1-beta1'],
['1.0.0', '2.0.0'],
['<=2.0.0', '2.1.1'],
['<=2.0.0', '3.2.9'],
['<2.0.0', '2.0.0'],
['0.1.20 || 1.2.4', '1.2.5'],
['2.x.x', '3.0.0'],
['1.2.x', '1.3.0'],
['1.2.x || 2.x', '3.0.0'],
['2.*.*', '5.0.1'],
['1.2.*', '1.3.3'],
['1.2.* || 2.*', '4.0.0'],
['2', '3.0.0'],
['2.3', '2.4.2'],
['~2.4', '2.5.0'], // >=2.4.0 <2.5.0
['~2.4', '2.5.5'],
['~>3.2.1', '3.3.0'], // >=3.2.1 <3.3.0
['~1', '2.2.3'], // >=1.0.0 <2.0.0
['~>1', '2.2.4'],
['~> 1', '3.2.3'],
['~1.0', '1.1.2'], // >=1.0.0 <1.1.0
['~ 1.0', '1.1.0'],
['<1.2', '1.2.0'],
['< 1.2', '1.2.1'],
['1', '2.0.0beta', true],
['~v0.5.4-pre', '0.6.0'],
['~v0.5.4-pre', '0.6.1-pre'],
['=0.7.x', '0.8.0'],
['=0.7.x', '0.8.0-asdf'],
['<0.7.x', '0.7.0'],
['~1.2.2', '1.3.0'],
['1.0.0 - 2.0.0', '2.2.3'],
['1.0.0', '1.0.1'],
['<=2.0.0', '3.0.0'],
['<=2.0.0', '2.9999.9999'],
['<=2.0.0', '2.2.9'],
['<2.0.0', '2.9999.9999'],
['<2.0.0', '2.2.9'],
['2.x.x', '3.1.3'],
['1.2.x', '1.3.3'],
['1.2.x || 2.x', '3.1.3'],
['2.*.*', '3.1.3'],
['1.2.*', '1.3.3'],
['1.2.* || 2.*', '3.1.3'],
['2', '3.1.2'],
['2.3', '2.4.1'],
['~2.4', '2.5.0'], // >=2.4.0 <2.5.0
['~>3.2.1', '3.3.2'], // >=3.2.1 <3.3.0
['~1', '2.2.3'], // >=1.0.0 <2.0.0
['~>1', '2.2.3'],
['~1.0', '1.1.0'], // >=1.0.0 <1.1.0
['<1', '1.0.0'],
['1', '2.0.0beta', true],
['<1', '1.0.0beta', true],
['< 1', '1.0.0beta', true],
['=0.7.x', '0.8.2'],
['<0.7.x', '0.7.2']
].forEach(function(tuple) {
var range = tuple[0];
var version = tuple[1];
var loose = tuple[2] || false;
var msg = 'gtr(' + version + ', ' + range + ', ' + loose + ')';
t.ok(gtr(version, range, loose), msg);
});
t.end();
});
test('\nnegative gtr tests', function(t) {
// [range, version, loose]
// Version should NOT be greater than range
[
['~0.6.1-1', '0.6.1-1'],
['1.0.0 - 2.0.0', '1.2.3'],
['1.0.0 - 2.0.0', '0.9.9'],
['1.0.0', '1.0.0'],
['>=*', '0.2.4'],
['', '1.0.0', true],
['*', '1.2.3'],
['*', 'v1.2.3-foo'],
['>=1.0.0', '1.0.0'],
['>=1.0.0', '1.0.1'],
['>=1.0.0', '1.1.0'],
['>1.0.0', '1.0.1'],
['>1.0.0', '1.1.0'],
['<=2.0.0', '2.0.0'],
['<=2.0.0', '1.9999.9999'],
['<=2.0.0', '0.2.9'],
['<2.0.0', '1.9999.9999'],
['<2.0.0', '0.2.9'],
['>= 1.0.0', '1.0.0'],
['>= 1.0.0', '1.0.1'],
['>= 1.0.0', '1.1.0'],
['> 1.0.0', '1.0.1'],
['> 1.0.0', '1.1.0'],
['<= 2.0.0', '2.0.0'],
['<= 2.0.0', '1.9999.9999'],
['<= 2.0.0', '0.2.9'],
['< 2.0.0', '1.9999.9999'],
['<\t2.0.0', '0.2.9'],
['>=0.1.97', 'v0.1.97'],
['>=0.1.97', '0.1.97'],
['0.1.20 || 1.2.4', '1.2.4'],
['0.1.20 || >1.2.4', '1.2.4'],
['0.1.20 || 1.2.4', '1.2.3'],
['0.1.20 || 1.2.4', '0.1.20'],
['>=0.2.3 || <0.0.1', '0.0.0'],
['>=0.2.3 || <0.0.1', '0.2.3'],
['>=0.2.3 || <0.0.1', '0.2.4'],
['||', '1.3.4'],
['2.x.x', '2.1.3'],
['1.2.x', '1.2.3'],
['1.2.x || 2.x', '2.1.3'],
['1.2.x || 2.x', '1.2.3'],
['x', '1.2.3'],
['2.*.*', '2.1.3'],
['1.2.*', '1.2.3'],
['1.2.* || 2.*', '2.1.3'],
['1.2.* || 2.*', '1.2.3'],
['1.2.* || 2.*', '1.2.3'],
['*', '1.2.3'],
['2', '2.1.2'],
['2.3', '2.3.1'],
['~2.4', '2.4.0'], // >=2.4.0 <2.5.0
['~2.4', '2.4.5'],
['~>3.2.1', '3.2.2'], // >=3.2.1 <3.3.0
['~1', '1.2.3'], // >=1.0.0 <2.0.0
['~>1', '1.2.3'],
['~> 1', '1.2.3'],
['~1.0', '1.0.2'], // >=1.0.0 <1.1.0
['~ 1.0', '1.0.2'],
['>=1', '1.0.0'],
['>= 1', '1.0.0'],
['<1.2', '1.1.1'],
['< 1.2', '1.1.1'],
['1', '1.0.0beta', true],
['~v0.5.4-pre', '0.5.5'],
['~v0.5.4-pre', '0.5.4'],
['=0.7.x', '0.7.2'],
['>=0.7.x', '0.7.2'],
['=0.7.x', '0.7.0-asdf'],
['>=0.7.x', '0.7.0-asdf'],
['<=0.7.x', '0.6.2'],
['>0.2.3 >0.2.4 <=0.2.5', '0.2.5'],
['>=0.2.3 <=0.2.4', '0.2.4'],
['1.0.0 - 2.0.0', '2.0.0'],
['^1', '0.0.0-0'],
['^3.0.0', '2.0.0'],
['^1.0.0 || ~2.0.1', '2.0.0'],
['^0.1.0 || ~3.0.1 || 5.0.0', '3.2.0'],
['^0.1.0 || ~3.0.1 || 5.0.0', '1.0.0beta', true],
['^0.1.0 || ~3.0.1 || 5.0.0', '5.0.0-0', true],
['^0.1.0 || ~3.0.1 || >4 <=5.0.0', '3.5.0']
].forEach(function(tuple) {
var range = tuple[0];
var version = tuple[1];
var loose = tuple[2] || false;
var msg = '!gtr(' + version + ', ' + range + ', ' + loose + ')';
t.notOk(gtr(version, range, loose), msg);
});
t.end();
});

View File

@ -0,0 +1,684 @@
'use strict';
var tap = require('tap');
var test = tap.test;
var semver = require('../semver.js');
var eq = semver.eq;
var gt = semver.gt;
var lt = semver.lt;
var neq = semver.neq;
var cmp = semver.cmp;
var gte = semver.gte;
var lte = semver.lte;
var satisfies = semver.satisfies;
var validRange = semver.validRange;
var inc = semver.inc;
var diff = semver.diff;
var replaceStars = semver.replaceStars;
var toComparators = semver.toComparators;
var SemVer = semver.SemVer;
var Range = semver.Range;
test('\ncomparison tests', function(t) {
// [version1, version2]
// version1 should be greater than version2
[['0.0.0', '0.0.0-foo'],
['0.0.1', '0.0.0'],
['1.0.0', '0.9.9'],
['0.10.0', '0.9.0'],
['0.99.0', '0.10.0'],
['2.0.0', '1.2.3'],
['v0.0.0', '0.0.0-foo', true],
['v0.0.1', '0.0.0', true],
['v1.0.0', '0.9.9', true],
['v0.10.0', '0.9.0', true],
['v0.99.0', '0.10.0', true],
['v2.0.0', '1.2.3', true],
['0.0.0', 'v0.0.0-foo', true],
['0.0.1', 'v0.0.0', true],
['1.0.0', 'v0.9.9', true],
['0.10.0', 'v0.9.0', true],
['0.99.0', 'v0.10.0', true],
['2.0.0', 'v1.2.3', true],
['1.2.3', '1.2.3-asdf'],
['1.2.3', '1.2.3-4'],
['1.2.3', '1.2.3-4-foo'],
['1.2.3-5-foo', '1.2.3-5'],
['1.2.3-5', '1.2.3-4'],
['1.2.3-5-foo', '1.2.3-5-Foo'],
['3.0.0', '2.7.2+asdf'],
['1.2.3-a.10', '1.2.3-a.5'],
['1.2.3-a.b', '1.2.3-a.5'],
['1.2.3-a.b', '1.2.3-a'],
['1.2.3-a.b.c.10.d.5', '1.2.3-a.b.c.5.d.100'],
['1.2.3-r2', '1.2.3-r100'],
['1.2.3-r100', '1.2.3-R2']
].forEach(function(v) {
var v0 = v[0];
var v1 = v[1];
var loose = v[2];
t.ok(gt(v0, v1, loose), "gt('" + v0 + "', '" + v1 + "')");
t.ok(lt(v1, v0, loose), "lt('" + v1 + "', '" + v0 + "')");
t.ok(!gt(v1, v0, loose), "!gt('" + v1 + "', '" + v0 + "')");
t.ok(!lt(v0, v1, loose), "!lt('" + v0 + "', '" + v1 + "')");
t.ok(eq(v0, v0, loose), "eq('" + v0 + "', '" + v0 + "')");
t.ok(eq(v1, v1, loose), "eq('" + v1 + "', '" + v1 + "')");
t.ok(neq(v0, v1, loose), "neq('" + v0 + "', '" + v1 + "')");
t.ok(cmp(v1, '==', v1, loose), "cmp('" + v1 + "' == '" + v1 + "')");
t.ok(cmp(v0, '>=', v1, loose), "cmp('" + v0 + "' >= '" + v1 + "')");
t.ok(cmp(v1, '<=', v0, loose), "cmp('" + v1 + "' <= '" + v0 + "')");
t.ok(cmp(v0, '!=', v1, loose), "cmp('" + v0 + "' != '" + v1 + "')");
});
t.end();
});
test('\nequality tests', function(t) {
// [version1, version2]
// version1 should be equivalent to version2
[['1.2.3', 'v1.2.3', true],
['1.2.3', '=1.2.3', true],
['1.2.3', 'v 1.2.3', true],
['1.2.3', '= 1.2.3', true],
['1.2.3', ' v1.2.3', true],
['1.2.3', ' =1.2.3', true],
['1.2.3', ' v 1.2.3', true],
['1.2.3', ' = 1.2.3', true],
['1.2.3-0', 'v1.2.3-0', true],
['1.2.3-0', '=1.2.3-0', true],
['1.2.3-0', 'v 1.2.3-0', true],
['1.2.3-0', '= 1.2.3-0', true],
['1.2.3-0', ' v1.2.3-0', true],
['1.2.3-0', ' =1.2.3-0', true],
['1.2.3-0', ' v 1.2.3-0', true],
['1.2.3-0', ' = 1.2.3-0', true],
['1.2.3-1', 'v1.2.3-1', true],
['1.2.3-1', '=1.2.3-1', true],
['1.2.3-1', 'v 1.2.3-1', true],
['1.2.3-1', '= 1.2.3-1', true],
['1.2.3-1', ' v1.2.3-1', true],
['1.2.3-1', ' =1.2.3-1', true],
['1.2.3-1', ' v 1.2.3-1', true],
['1.2.3-1', ' = 1.2.3-1', true],
['1.2.3-beta', 'v1.2.3-beta', true],
['1.2.3-beta', '=1.2.3-beta', true],
['1.2.3-beta', 'v 1.2.3-beta', true],
['1.2.3-beta', '= 1.2.3-beta', true],
['1.2.3-beta', ' v1.2.3-beta', true],
['1.2.3-beta', ' =1.2.3-beta', true],
['1.2.3-beta', ' v 1.2.3-beta', true],
['1.2.3-beta', ' = 1.2.3-beta', true],
['1.2.3-beta+build', ' = 1.2.3-beta+otherbuild', true],
['1.2.3+build', ' = 1.2.3+otherbuild', true],
['1.2.3-beta+build', '1.2.3-beta+otherbuild'],
['1.2.3+build', '1.2.3+otherbuild'],
[' v1.2.3+build', '1.2.3+otherbuild']
].forEach(function(v) {
var v0 = v[0];
var v1 = v[1];
var loose = v[2];
t.ok(eq(v0, v1, loose), "eq('" + v0 + "', '" + v1 + "')");
t.ok(!neq(v0, v1, loose), "!neq('" + v0 + "', '" + v1 + "')");
t.ok(cmp(v0, '==', v1, loose), 'cmp(' + v0 + '==' + v1 + ')');
t.ok(!cmp(v0, '!=', v1, loose), '!cmp(' + v0 + '!=' + v1 + ')');
t.ok(!cmp(v0, '===', v1, loose), '!cmp(' + v0 + '===' + v1 + ')');
t.ok(cmp(v0, '!==', v1, loose), 'cmp(' + v0 + '!==' + v1 + ')');
t.ok(!gt(v0, v1, loose), "!gt('" + v0 + "', '" + v1 + "')");
t.ok(gte(v0, v1, loose), "gte('" + v0 + "', '" + v1 + "')");
t.ok(!lt(v0, v1, loose), "!lt('" + v0 + "', '" + v1 + "')");
t.ok(lte(v0, v1, loose), "lte('" + v0 + "', '" + v1 + "')");
});
t.end();
});
test('\nrange tests', function(t) {
// [range, version]
// version should be included by range
[['1.0.0 - 2.0.0', '1.2.3'],
['^1.2.3+build', '1.2.3'],
['^1.2.3+build', '1.3.0'],
['1.2.3-pre+asdf - 2.4.3-pre+asdf', '1.2.3'],
['1.2.3pre+asdf - 2.4.3-pre+asdf', '1.2.3', true],
['1.2.3-pre+asdf - 2.4.3pre+asdf', '1.2.3', true],
['1.2.3pre+asdf - 2.4.3pre+asdf', '1.2.3', true],
['1.2.3-pre+asdf - 2.4.3-pre+asdf', '1.2.3-pre.2'],
['1.2.3-pre+asdf - 2.4.3-pre+asdf', '2.4.3-alpha'],
['1.2.3+asdf - 2.4.3+asdf', '1.2.3'],
['1.0.0', '1.0.0'],
['>=*', '0.2.4'],
['', '1.0.0'],
['*', '1.2.3'],
['*', 'v1.2.3-foo', true],
['>=1.0.0', '1.0.0'],
['>=1.0.0', '1.0.1'],
['>=1.0.0', '1.1.0'],
['>1.0.0', '1.0.1'],
['>1.0.0', '1.1.0'],
['<=2.0.0', '2.0.0'],
['<=2.0.0', '1.9999.9999'],
['<=2.0.0', '0.2.9'],
['<2.0.0', '1.9999.9999'],
['<2.0.0', '0.2.9'],
['>= 1.0.0', '1.0.0'],
['>= 1.0.0', '1.0.1'],
['>= 1.0.0', '1.1.0'],
['> 1.0.0', '1.0.1'],
['> 1.0.0', '1.1.0'],
['<= 2.0.0', '2.0.0'],
['<= 2.0.0', '1.9999.9999'],
['<= 2.0.0', '0.2.9'],
['< 2.0.0', '1.9999.9999'],
['<\t2.0.0', '0.2.9'],
['>=0.1.97', 'v0.1.97', true],
['>=0.1.97', '0.1.97'],
['0.1.20 || 1.2.4', '1.2.4'],
['>=0.2.3 || <0.0.1', '0.0.0'],
['>=0.2.3 || <0.0.1', '0.2.3'],
['>=0.2.3 || <0.0.1', '0.2.4'],
['||', '1.3.4'],
['2.x.x', '2.1.3'],
['1.2.x', '1.2.3'],
['1.2.x || 2.x', '2.1.3'],
['1.2.x || 2.x', '1.2.3'],
['x', '1.2.3'],
['2.*.*', '2.1.3'],
['1.2.*', '1.2.3'],
['1.2.* || 2.*', '2.1.3'],
['1.2.* || 2.*', '1.2.3'],
['*', '1.2.3'],
['2', '2.1.2'],
['2.3', '2.3.1'],
['~2.4', '2.4.0'], // >=2.4.0 <2.5.0
['~2.4', '2.4.5'],
['~>3.2.1', '3.2.2'], // >=3.2.1 <3.3.0,
['~1', '1.2.3'], // >=1.0.0 <2.0.0
['~>1', '1.2.3'],
['~> 1', '1.2.3'],
['~1.0', '1.0.2'], // >=1.0.0 <1.1.0,
['~ 1.0', '1.0.2'],
['~ 1.0.3', '1.0.12'],
['>=1', '1.0.0'],
['>= 1', '1.0.0'],
['<1.2', '1.1.1'],
['< 1.2', '1.1.1'],
['~v0.5.4-pre', '0.5.5'],
['~v0.5.4-pre', '0.5.4'],
['=0.7.x', '0.7.2'],
['<=0.7.x', '0.7.2'],
['>=0.7.x', '0.7.2'],
['<=0.7.x', '0.6.2'],
['~1.2.1 >=1.2.3', '1.2.3'],
['~1.2.1 =1.2.3', '1.2.3'],
['~1.2.1 1.2.3', '1.2.3'],
['~1.2.1 >=1.2.3 1.2.3', '1.2.3'],
['~1.2.1 1.2.3 >=1.2.3', '1.2.3'],
['~1.2.1 1.2.3', '1.2.3'],
['>=1.2.1 1.2.3', '1.2.3'],
['1.2.3 >=1.2.1', '1.2.3'],
['>=1.2.3 >=1.2.1', '1.2.3'],
['>=1.2.1 >=1.2.3', '1.2.3'],
['>=1.2', '1.2.8'],
['^1.2.3', '1.8.1'],
['^0.1.2', '0.1.2'],
['^0.1', '0.1.2'],
['^1.2', '1.4.2'],
['^1.2 ^1', '1.4.2'],
['^1.2.3-alpha', '1.2.3-pre'],
['^1.2.0-alpha', '1.2.0-pre'],
['^0.0.1-alpha', '0.0.1-beta']
].forEach(function(v) {
var range = v[0];
var ver = v[1];
var loose = v[2];
t.ok(satisfies(ver, range, loose), range + ' satisfied by ' + ver);
});
t.end();
});
test('\nnegative range tests', function(t) {
// [range, version]
// version should not be included by range
[['1.0.0 - 2.0.0', '2.2.3'],
['1.2.3+asdf - 2.4.3+asdf', '1.2.3-pre.2'],
['1.2.3+asdf - 2.4.3+asdf', '2.4.3-alpha'],
['^1.2.3+build', '2.0.0'],
['^1.2.3+build', '1.2.0'],
['^1.2.3', '1.2.3-pre'],
['^1.2', '1.2.0-pre'],
['>1.2', '1.3.0-beta'],
['<=1.2.3', '1.2.3-beta'],
['^1.2.3', '1.2.3-beta'],
['=0.7.x', '0.7.0-asdf'],
['>=0.7.x', '0.7.0-asdf'],
['1', '1.0.0beta', true],
['<1', '1.0.0beta', true],
['< 1', '1.0.0beta', true],
['1.0.0', '1.0.1'],
['>=1.0.0', '0.0.0'],
['>=1.0.0', '0.0.1'],
['>=1.0.0', '0.1.0'],
['>1.0.0', '0.0.1'],
['>1.0.0', '0.1.0'],
['<=2.0.0', '3.0.0'],
['<=2.0.0', '2.9999.9999'],
['<=2.0.0', '2.2.9'],
['<2.0.0', '2.9999.9999'],
['<2.0.0', '2.2.9'],
['>=0.1.97', 'v0.1.93', true],
['>=0.1.97', '0.1.93'],
['0.1.20 || 1.2.4', '1.2.3'],
['>=0.2.3 || <0.0.1', '0.0.3'],
['>=0.2.3 || <0.0.1', '0.2.2'],
['2.x.x', '1.1.3'],
['2.x.x', '3.1.3'],
['1.2.x', '1.3.3'],
['1.2.x || 2.x', '3.1.3'],
['1.2.x || 2.x', '1.1.3'],
['2.*.*', '1.1.3'],
['2.*.*', '3.1.3'],
['1.2.*', '1.3.3'],
['1.2.* || 2.*', '3.1.3'],
['1.2.* || 2.*', '1.1.3'],
['2', '1.1.2'],
['2.3', '2.4.1'],
['~2.4', '2.5.0'], // >=2.4.0 <2.5.0
['~2.4', '2.3.9'],
['~>3.2.1', '3.3.2'], // >=3.2.1 <3.3.0
['~>3.2.1', '3.2.0'], // >=3.2.1 <3.3.0
['~1', '0.2.3'], // >=1.0.0 <2.0.0
['~>1', '2.2.3'],
['~1.0', '1.1.0'], // >=1.0.0 <1.1.0
['<1', '1.0.0'],
['>=1.2', '1.1.1'],
['1', '2.0.0beta', true],
['~v0.5.4-beta', '0.5.4-alpha'],
['=0.7.x', '0.8.2'],
['>=0.7.x', '0.6.2'],
['<0.7.x', '0.7.2'],
['<1.2.3', '1.2.3-beta'],
['=1.2.3', '1.2.3-beta'],
['>1.2', '1.2.8'],
['^1.2.3', '2.0.0-alpha'],
['^1.2.3', '1.2.2'],
['^1.2', '1.1.9'],
// invalid ranges never satisfied!
['blerg', '1.2.3'],
['git+https://user:password0123@github.com/foo', '123.0.0', true],
['^1.2.3', '2.0.0-pre']
].forEach(function(v) {
var range = v[0];
var ver = v[1];
var loose = v[2];
var found = satisfies(ver, range, loose);
t.ok(!found, ver + ' not satisfied by ' + range);
});
t.end();
});
test('\nincrement versions test', function(t) {
// [version, inc, result, identifier]
// inc(version, inc) -> result
[['1.2.3', 'major', '2.0.0'],
['1.2.3', 'minor', '1.3.0'],
['1.2.3', 'patch', '1.2.4'],
['1.2.3tag', 'major', '2.0.0', true],
['1.2.3-tag', 'major', '2.0.0'],
['1.2.3', 'fake', null],
['1.2.0-0', 'patch', '1.2.0'],
['fake', 'major', null],
['1.2.3-4', 'major', '2.0.0'],
['1.2.3-4', 'minor', '1.3.0'],
['1.2.3-4', 'patch', '1.2.3'],
['1.2.3-alpha.0.beta', 'major', '2.0.0'],
['1.2.3-alpha.0.beta', 'minor', '1.3.0'],
['1.2.3-alpha.0.beta', 'patch', '1.2.3'],
['1.2.4', 'prerelease', '1.2.5-0'],
['1.2.3-0', 'prerelease', '1.2.3-1'],
['1.2.3-alpha.0', 'prerelease', '1.2.3-alpha.1'],
['1.2.3-alpha.1', 'prerelease', '1.2.3-alpha.2'],
['1.2.3-alpha.2', 'prerelease', '1.2.3-alpha.3'],
['1.2.3-alpha.0.beta', 'prerelease', '1.2.3-alpha.1.beta'],
['1.2.3-alpha.1.beta', 'prerelease', '1.2.3-alpha.2.beta'],
['1.2.3-alpha.2.beta', 'prerelease', '1.2.3-alpha.3.beta'],
['1.2.3-alpha.10.0.beta', 'prerelease', '1.2.3-alpha.10.1.beta'],
['1.2.3-alpha.10.1.beta', 'prerelease', '1.2.3-alpha.10.2.beta'],
['1.2.3-alpha.10.2.beta', 'prerelease', '1.2.3-alpha.10.3.beta'],
['1.2.3-alpha.10.beta.0', 'prerelease', '1.2.3-alpha.10.beta.1'],
['1.2.3-alpha.10.beta.1', 'prerelease', '1.2.3-alpha.10.beta.2'],
['1.2.3-alpha.10.beta.2', 'prerelease', '1.2.3-alpha.10.beta.3'],
['1.2.3-alpha.9.beta', 'prerelease', '1.2.3-alpha.10.beta'],
['1.2.3-alpha.10.beta', 'prerelease', '1.2.3-alpha.11.beta'],
['1.2.3-alpha.11.beta', 'prerelease', '1.2.3-alpha.12.beta'],
['1.2.0', 'prepatch', '1.2.1-0'],
['1.2.0-1', 'prepatch', '1.2.1-0'],
['1.2.0', 'preminor', '1.3.0-0'],
['1.2.3-1', 'preminor', '1.3.0-0'],
['1.2.0', 'premajor', '2.0.0-0'],
['1.2.3-1', 'premajor', '2.0.0-0'],
['1.2.0-1', 'minor', '1.2.0'],
['1.0.0-1', 'major', '1.0.0'],
['1.2.3', 'major', '2.0.0', false, 'dev'],
['1.2.3', 'minor', '1.3.0', false, 'dev'],
['1.2.3', 'patch', '1.2.4', false, 'dev'],
['1.2.3tag', 'major', '2.0.0', true, 'dev'],
['1.2.3-tag', 'major', '2.0.0', false, 'dev'],
['1.2.3', 'fake', null, false, 'dev'],
['1.2.0-0', 'patch', '1.2.0', false, 'dev'],
['fake', 'major', null, false, 'dev'],
['1.2.3-4', 'major', '2.0.0', false, 'dev'],
['1.2.3-4', 'minor', '1.3.0', false, 'dev'],
['1.2.3-4', 'patch', '1.2.3', false, 'dev'],
['1.2.3-alpha.0.beta', 'major', '2.0.0', false, 'dev'],
['1.2.3-alpha.0.beta', 'minor', '1.3.0', false, 'dev'],
['1.2.3-alpha.0.beta', 'patch', '1.2.3', false, 'dev'],
['1.2.4', 'prerelease', '1.2.5-dev.0', false, 'dev'],
['1.2.3-0', 'prerelease', '1.2.3-dev.0', false, 'dev'],
['1.2.3-alpha.0', 'prerelease', '1.2.3-dev.0', false, 'dev'],
['1.2.3-alpha.0', 'prerelease', '1.2.3-alpha.1', false, 'alpha'],
['1.2.3-alpha.0.beta', 'prerelease', '1.2.3-dev.0', false, 'dev'],
['1.2.3-alpha.0.beta', 'prerelease', '1.2.3-alpha.1.beta', false, 'alpha'],
['1.2.3-alpha.10.0.beta', 'prerelease', '1.2.3-dev.0', false, 'dev'],
['1.2.3-alpha.10.0.beta', 'prerelease', '1.2.3-alpha.10.1.beta', false, 'alpha'],
['1.2.3-alpha.10.1.beta', 'prerelease', '1.2.3-alpha.10.2.beta', false, 'alpha'],
['1.2.3-alpha.10.2.beta', 'prerelease', '1.2.3-alpha.10.3.beta', false, 'alpha'],
['1.2.3-alpha.10.beta.0', 'prerelease', '1.2.3-dev.0', false, 'dev'],
['1.2.3-alpha.10.beta.0', 'prerelease', '1.2.3-alpha.10.beta.1', false, 'alpha'],
['1.2.3-alpha.10.beta.1', 'prerelease', '1.2.3-alpha.10.beta.2', false, 'alpha'],
['1.2.3-alpha.10.beta.2', 'prerelease', '1.2.3-alpha.10.beta.3', false, 'alpha'],
['1.2.3-alpha.9.beta', 'prerelease', '1.2.3-dev.0', false, 'dev'],
['1.2.3-alpha.9.beta', 'prerelease', '1.2.3-alpha.10.beta', false, 'alpha'],
['1.2.3-alpha.10.beta', 'prerelease', '1.2.3-alpha.11.beta', false, 'alpha'],
['1.2.3-alpha.11.beta', 'prerelease', '1.2.3-alpha.12.beta', false, 'alpha'],
['1.2.0', 'prepatch', '1.2.1-dev.0', 'dev'],
['1.2.0-1', 'prepatch', '1.2.1-dev.0', 'dev'],
['1.2.0', 'preminor', '1.3.0-dev.0', 'dev'],
['1.2.3-1', 'preminor', '1.3.0-dev.0', 'dev'],
['1.2.0', 'premajor', '2.0.0-dev.0', 'dev'],
['1.2.3-1', 'premajor', '2.0.0-dev.0', 'dev'],
['1.2.0-1', 'minor', '1.2.0', 'dev'],
['1.0.0-1', 'major', '1.0.0', 'dev'],
['1.2.3-dev.bar', 'prerelease', '1.2.3-dev.0', false, 'dev']
].forEach(function(v) {
var pre = v[0];
var what = v[1];
var wanted = v[2];
var loose = v[3];
var id = v[4];
var found = inc(pre, what, loose, id);
var cmd = 'inc(' + pre + ', ' + what + ', ' + id + ')';
t.equal(found, wanted, cmd + ' === ' + wanted);
});
t.end();
});
test('\ndiff versions test', function(t) {
// [version1, version2, result]
// diff(version1, version2) -> result
[['1.2.3', '0.2.3', 'major'],
['1.4.5', '0.2.3', 'major'],
['1.2.3', '2.0.0-pre', 'premajor'],
['1.2.3', '1.3.3', 'minor'],
['1.0.1', '1.1.0-pre', 'preminor'],
['1.2.3', '1.2.4', 'patch'],
['1.2.3', '1.2.4-pre', 'prepatch'],
['0.0.1', '0.0.1-pre', 'prerelease'],
['0.0.1', '0.0.1-pre-2', 'prerelease'],
['1.1.0', '1.1.0-pre', 'prerelease'],
['1.1.0-pre-1', '1.1.0-pre-2', 'prerelease'],
['1.0.0', '1.0.0', null]
].forEach(function(v) {
var version1 = v[0];
var version2 = v[1];
var wanted = v[2];
var found = diff(version1, version2);
var cmd = 'diff(' + version1 + ', ' + version2 + ')';
t.equal(found, wanted, cmd + ' === ' + wanted);
});
t.end();
});
test('\nvalid range test', function(t) {
// [range, result]
// validRange(range) -> result
// translate ranges into their canonical form
[['1.0.0 - 2.0.0', '>=1.0.0 <=2.0.0'],
['1.0.0', '1.0.0'],
['>=*', '*'],
['', '*'],
['*', '*'],
['*', '*'],
['>=1.0.0', '>=1.0.0'],
['>1.0.0', '>1.0.0'],
['<=2.0.0', '<=2.0.0'],
['1', '>=1.0.0 <2.0.0'],
['<=2.0.0', '<=2.0.0'],
['<=2.0.0', '<=2.0.0'],
['<2.0.0', '<2.0.0'],
['<2.0.0', '<2.0.0'],
['>= 1.0.0', '>=1.0.0'],
['>= 1.0.0', '>=1.0.0'],
['>= 1.0.0', '>=1.0.0'],
['> 1.0.0', '>1.0.0'],
['> 1.0.0', '>1.0.0'],
['<= 2.0.0', '<=2.0.0'],
['<= 2.0.0', '<=2.0.0'],
['<= 2.0.0', '<=2.0.0'],
['< 2.0.0', '<2.0.0'],
['< 2.0.0', '<2.0.0'],
['>=0.1.97', '>=0.1.97'],
['>=0.1.97', '>=0.1.97'],
['0.1.20 || 1.2.4', '0.1.20||1.2.4'],
['>=0.2.3 || <0.0.1', '>=0.2.3||<0.0.1'],
['>=0.2.3 || <0.0.1', '>=0.2.3||<0.0.1'],
['>=0.2.3 || <0.0.1', '>=0.2.3||<0.0.1'],
['||', '||'],
['2.x.x', '>=2.0.0 <3.0.0'],
['1.2.x', '>=1.2.0 <1.3.0'],
['1.2.x || 2.x', '>=1.2.0 <1.3.0||>=2.0.0 <3.0.0'],
['1.2.x || 2.x', '>=1.2.0 <1.3.0||>=2.0.0 <3.0.0'],
['x', '*'],
['2.*.*', '>=2.0.0 <3.0.0'],
['1.2.*', '>=1.2.0 <1.3.0'],
['1.2.* || 2.*', '>=1.2.0 <1.3.0||>=2.0.0 <3.0.0'],
['*', '*'],
['2', '>=2.0.0 <3.0.0'],
['2.3', '>=2.3.0 <2.4.0'],
['~2.4', '>=2.4.0 <2.5.0'],
['~2.4', '>=2.4.0 <2.5.0'],
['~>3.2.1', '>=3.2.1 <3.3.0'],
['~1', '>=1.0.0 <2.0.0'],
['~>1', '>=1.0.0 <2.0.0'],
['~> 1', '>=1.0.0 <2.0.0'],
['~1.0', '>=1.0.0 <1.1.0'],
['~ 1.0', '>=1.0.0 <1.1.0'],
['^0', '>=0.0.0 <1.0.0'],
['^ 1', '>=1.0.0 <2.0.0'],
['^0.1', '>=0.1.0 <0.2.0'],
['^1.0', '>=1.0.0 <2.0.0'],
['^1.2', '>=1.2.0 <2.0.0'],
['^0.0.1', '>=0.0.1 <0.0.2'],
['^0.0.1-beta', '>=0.0.1-beta <0.0.2'],
['^0.1.2', '>=0.1.2 <0.2.0'],
['^1.2.3', '>=1.2.3 <2.0.0'],
['^1.2.3-beta.4', '>=1.2.3-beta.4 <2.0.0'],
['<1', '<1.0.0'],
['< 1', '<1.0.0'],
['>=1', '>=1.0.0'],
['>= 1', '>=1.0.0'],
['<1.2', '<1.2.0'],
['< 1.2', '<1.2.0'],
['1', '>=1.0.0 <2.0.0'],
['>01.02.03', '>1.2.3', true],
['>01.02.03', null],
['~1.2.3beta', '>=1.2.3-beta <1.3.0', true],
['~1.2.3beta', null],
['^ 1.2 ^ 1', '>=1.2.0 <2.0.0 >=1.0.0 <2.0.0']
].forEach(function(v) {
var pre = v[0];
var wanted = v[1];
var loose = v[2];
var found = validRange(pre, loose);
t.equal(found, wanted, 'validRange(' + pre + ') === ' + wanted);
});
t.end();
});
test('\ncomparators test', function(t) {
// [range, comparators]
// turn range into a set of individual comparators
[['1.0.0 - 2.0.0', [['>=1.0.0', '<=2.0.0']]],
['1.0.0', [['1.0.0']]],
['>=*', [['']]],
['', [['']]],
['*', [['']]],
['*', [['']]],
['>=1.0.0', [['>=1.0.0']]],
['>=1.0.0', [['>=1.0.0']]],
['>=1.0.0', [['>=1.0.0']]],
['>1.0.0', [['>1.0.0']]],
['>1.0.0', [['>1.0.0']]],
['<=2.0.0', [['<=2.0.0']]],
['1', [['>=1.0.0', '<2.0.0']]],
['<=2.0.0', [['<=2.0.0']]],
['<=2.0.0', [['<=2.0.0']]],
['<2.0.0', [['<2.0.0']]],
['<2.0.0', [['<2.0.0']]],
['>= 1.0.0', [['>=1.0.0']]],
['>= 1.0.0', [['>=1.0.0']]],
['>= 1.0.0', [['>=1.0.0']]],
['> 1.0.0', [['>1.0.0']]],
['> 1.0.0', [['>1.0.0']]],
['<= 2.0.0', [['<=2.0.0']]],
['<= 2.0.0', [['<=2.0.0']]],
['<= 2.0.0', [['<=2.0.0']]],
['< 2.0.0', [['<2.0.0']]],
['<\t2.0.0', [['<2.0.0']]],
['>=0.1.97', [['>=0.1.97']]],
['>=0.1.97', [['>=0.1.97']]],
['0.1.20 || 1.2.4', [['0.1.20'], ['1.2.4']]],
['>=0.2.3 || <0.0.1', [['>=0.2.3'], ['<0.0.1']]],
['>=0.2.3 || <0.0.1', [['>=0.2.3'], ['<0.0.1']]],
['>=0.2.3 || <0.0.1', [['>=0.2.3'], ['<0.0.1']]],
['||', [[''], ['']]],
['2.x.x', [['>=2.0.0', '<3.0.0']]],
['1.2.x', [['>=1.2.0', '<1.3.0']]],
['1.2.x || 2.x', [['>=1.2.0', '<1.3.0'], ['>=2.0.0', '<3.0.0']]],
['1.2.x || 2.x', [['>=1.2.0', '<1.3.0'], ['>=2.0.0', '<3.0.0']]],
['x', [['']]],
['2.*.*', [['>=2.0.0', '<3.0.0']]],
['1.2.*', [['>=1.2.0', '<1.3.0']]],
['1.2.* || 2.*', [['>=1.2.0', '<1.3.0'], ['>=2.0.0', '<3.0.0']]],
['1.2.* || 2.*', [['>=1.2.0', '<1.3.0'], ['>=2.0.0', '<3.0.0']]],
['*', [['']]],
['2', [['>=2.0.0', '<3.0.0']]],
['2.3', [['>=2.3.0', '<2.4.0']]],
['~2.4', [['>=2.4.0', '<2.5.0']]],
['~2.4', [['>=2.4.0', '<2.5.0']]],
['~>3.2.1', [['>=3.2.1', '<3.3.0']]],
['~1', [['>=1.0.0', '<2.0.0']]],
['~>1', [['>=1.0.0', '<2.0.0']]],
['~> 1', [['>=1.0.0', '<2.0.0']]],
['~1.0', [['>=1.0.0', '<1.1.0']]],
['~ 1.0', [['>=1.0.0', '<1.1.0']]],
['~ 1.0.3', [['>=1.0.3', '<1.1.0']]],
['~> 1.0.3', [['>=1.0.3', '<1.1.0']]],
['<1', [['<1.0.0']]],
['< 1', [['<1.0.0']]],
['>=1', [['>=1.0.0']]],
['>= 1', [['>=1.0.0']]],
['<1.2', [['<1.2.0']]],
['< 1.2', [['<1.2.0']]],
['1', [['>=1.0.0', '<2.0.0']]],
['1 2', [['>=1.0.0', '<2.0.0', '>=2.0.0', '<3.0.0']]],
['1.2 - 3.4.5', [['>=1.2.0', '<=3.4.5']]],
['1.2.3 - 3.4', [['>=1.2.3', '<3.5.0']]],
['1.2.3 - 3', [['>=1.2.3', '<4.0.0']]],
['>*', [['<0.0.0']]],
['<*', [['<0.0.0']]]
].forEach(function(v) {
var pre = v[0];
var wanted = v[1];
var found = toComparators(v[0]);
var jw = JSON.stringify(wanted);
t.equivalent(found, wanted, 'toComparators(' + pre + ') === ' + jw);
});
t.end();
});
test('\ninvalid version numbers', function(t) {
['1.2.3.4',
'NOT VALID',
1.2,
null,
'Infinity.NaN.Infinity'
].forEach(function(v) {
t.throws(function() {
new SemVer(v);
}, {name:'TypeError', message:'Invalid Version: ' + v});
});
t.end();
});
test('\nstrict vs loose version numbers', function(t) {
[['=1.2.3', '1.2.3'],
['01.02.03', '1.2.3'],
['1.2.3-beta.01', '1.2.3-beta.1'],
[' =1.2.3', '1.2.3'],
['1.2.3foo', '1.2.3-foo']
].forEach(function(v) {
var loose = v[0];
var strict = v[1];
t.throws(function() {
new SemVer(loose);
});
var lv = new SemVer(loose, true);
t.equal(lv.version, strict);
t.ok(eq(loose, strict, true));
t.throws(function() {
eq(loose, strict);
});
t.throws(function() {
new SemVer(strict).compare(loose);
});
});
t.end();
});
test('\nstrict vs loose ranges', function(t) {
[['>=01.02.03', '>=1.2.3'],
['~1.02.03beta', '>=1.2.3-beta <1.3.0']
].forEach(function(v) {
var loose = v[0];
var comps = v[1];
t.throws(function() {
new Range(loose);
});
t.equal(new Range(loose, true).range, comps);
});
t.end();
});
test('\nmax satisfying', function(t) {
[[['1.2.3', '1.2.4'], '1.2', '1.2.4'],
[['1.2.4', '1.2.3'], '1.2', '1.2.4'],
[['1.2.3', '1.2.4', '1.2.5', '1.2.6'], '~1.2.3', '1.2.6'],
[['1.1.0', '1.2.0', '1.2.1', '1.3.0', '2.0.0b1', '2.0.0b2', '2.0.0b3', '2.0.0', '2.1.0'], '~2.0.0', '2.0.0', true]
].forEach(function(v) {
var versions = v[0];
var range = v[1];
var expect = v[2];
var loose = v[3];
var actual = semver.maxSatisfying(versions, range, loose);
t.equal(actual, expect);
});
t.end();
});

View File

@ -0,0 +1,181 @@
var tap = require('tap');
var test = tap.test;
var semver = require('../semver.js');
var ltr = semver.ltr;
test('\nltr tests', function(t) {
// [range, version, loose]
// Version should be less than range
[
['~1.2.2', '1.2.1'],
['~0.6.1-1', '0.6.1-0'],
['1.0.0 - 2.0.0', '0.0.1'],
['1.0.0-beta.2', '1.0.0-beta.1'],
['1.0.0', '0.0.0'],
['>=2.0.0', '1.1.1'],
['>=2.0.0', '1.2.9'],
['>2.0.0', '2.0.0'],
['0.1.20 || 1.2.4', '0.1.5'],
['2.x.x', '1.0.0'],
['1.2.x', '1.1.0'],
['1.2.x || 2.x', '1.0.0'],
['2.*.*', '1.0.1'],
['1.2.*', '1.1.3'],
['1.2.* || 2.*', '1.1.9999'],
['2', '1.0.0'],
['2.3', '2.2.2'],
['~2.4', '2.3.0'], // >=2.4.0 <2.5.0
['~2.4', '2.3.5'],
['~>3.2.1', '3.2.0'], // >=3.2.1 <3.3.0
['~1', '0.2.3'], // >=1.0.0 <2.0.0
['~>1', '0.2.4'],
['~> 1', '0.2.3'],
['~1.0', '0.1.2'], // >=1.0.0 <1.1.0
['~ 1.0', '0.1.0'],
['>1.2', '1.2.0'],
['> 1.2', '1.2.1'],
['1', '0.0.0beta', true],
['~v0.5.4-pre', '0.5.4-alpha'],
['~v0.5.4-pre', '0.5.4-alpha'],
['=0.7.x', '0.6.0'],
['=0.7.x', '0.6.0-asdf'],
['>=0.7.x', '0.6.0'],
['~1.2.2', '1.2.1'],
['1.0.0 - 2.0.0', '0.2.3'],
['1.0.0', '0.0.1'],
['>=2.0.0', '1.0.0'],
['>=2.0.0', '1.9999.9999'],
['>=2.0.0', '1.2.9'],
['>2.0.0', '2.0.0'],
['>2.0.0', '1.2.9'],
['2.x.x', '1.1.3'],
['1.2.x', '1.1.3'],
['1.2.x || 2.x', '1.1.3'],
['2.*.*', '1.1.3'],
['1.2.*', '1.1.3'],
['1.2.* || 2.*', '1.1.3'],
['2', '1.9999.9999'],
['2.3', '2.2.1'],
['~2.4', '2.3.0'], // >=2.4.0 <2.5.0
['~>3.2.1', '2.3.2'], // >=3.2.1 <3.3.0
['~1', '0.2.3'], // >=1.0.0 <2.0.0
['~>1', '0.2.3'],
['~1.0', '0.0.0'], // >=1.0.0 <1.1.0
['>1', '1.0.0'],
['2', '1.0.0beta', true],
['>1', '1.0.0beta', true],
['> 1', '1.0.0beta', true],
['=0.7.x', '0.6.2'],
['=0.7.x', '0.7.0-asdf'],
['^1', '1.0.0-0'],
['>=0.7.x', '0.7.0-asdf'],
['1', '1.0.0beta', true],
['>=0.7.x', '0.6.2']
].forEach(function(tuple) {
var range = tuple[0];
var version = tuple[1];
var loose = tuple[2] || false;
var msg = 'ltr(' + version + ', ' + range + ', ' + loose + ')';
t.ok(ltr(version, range, loose), msg);
});
t.end();
});
test('\nnegative ltr tests', function(t) {
// [range, version, loose]
// Version should NOT be greater than range
[
['~ 1.0', '1.1.0'],
['~0.6.1-1', '0.6.1-1'],
['1.0.0 - 2.0.0', '1.2.3'],
['1.0.0 - 2.0.0', '2.9.9'],
['1.0.0', '1.0.0'],
['>=*', '0.2.4'],
['', '1.0.0', true],
['*', '1.2.3'],
['*', 'v1.2.3-foo'],
['>=1.0.0', '1.0.0'],
['>=1.0.0', '1.0.1'],
['>=1.0.0', '1.1.0'],
['>1.0.0', '1.0.1'],
['>1.0.0', '1.1.0'],
['<=2.0.0', '2.0.0'],
['<=2.0.0', '1.9999.9999'],
['<=2.0.0', '0.2.9'],
['<2.0.0', '1.9999.9999'],
['<2.0.0', '0.2.9'],
['>= 1.0.0', '1.0.0'],
['>= 1.0.0', '1.0.1'],
['>= 1.0.0', '1.1.0'],
['> 1.0.0', '1.0.1'],
['> 1.0.0', '1.1.0'],
['<= 2.0.0', '2.0.0'],
['<= 2.0.0', '1.9999.9999'],
['<= 2.0.0', '0.2.9'],
['< 2.0.0', '1.9999.9999'],
['<\t2.0.0', '0.2.9'],
['>=0.1.97', 'v0.1.97'],
['>=0.1.97', '0.1.97'],
['0.1.20 || 1.2.4', '1.2.4'],
['0.1.20 || >1.2.4', '1.2.4'],
['0.1.20 || 1.2.4', '1.2.3'],
['0.1.20 || 1.2.4', '0.1.20'],
['>=0.2.3 || <0.0.1', '0.0.0'],
['>=0.2.3 || <0.0.1', '0.2.3'],
['>=0.2.3 || <0.0.1', '0.2.4'],
['||', '1.3.4'],
['2.x.x', '2.1.3'],
['1.2.x', '1.2.3'],
['1.2.x || 2.x', '2.1.3'],
['1.2.x || 2.x', '1.2.3'],
['x', '1.2.3'],
['2.*.*', '2.1.3'],
['1.2.*', '1.2.3'],
['1.2.* || 2.*', '2.1.3'],
['1.2.* || 2.*', '1.2.3'],
['1.2.* || 2.*', '1.2.3'],
['*', '1.2.3'],
['2', '2.1.2'],
['2.3', '2.3.1'],
['~2.4', '2.4.0'], // >=2.4.0 <2.5.0
['~2.4', '2.4.5'],
['~>3.2.1', '3.2.2'], // >=3.2.1 <3.3.0
['~1', '1.2.3'], // >=1.0.0 <2.0.0
['~>1', '1.2.3'],
['~> 1', '1.2.3'],
['~1.0', '1.0.2'], // >=1.0.0 <1.1.0
['~ 1.0', '1.0.2'],
['>=1', '1.0.0'],
['>= 1', '1.0.0'],
['<1.2', '1.1.1'],
['< 1.2', '1.1.1'],
['~v0.5.4-pre', '0.5.5'],
['~v0.5.4-pre', '0.5.4'],
['=0.7.x', '0.7.2'],
['>=0.7.x', '0.7.2'],
['<=0.7.x', '0.6.2'],
['>0.2.3 >0.2.4 <=0.2.5', '0.2.5'],
['>=0.2.3 <=0.2.4', '0.2.4'],
['1.0.0 - 2.0.0', '2.0.0'],
['^3.0.0', '4.0.0'],
['^1.0.0 || ~2.0.1', '2.0.0'],
['^0.1.0 || ~3.0.1 || 5.0.0', '3.2.0'],
['^0.1.0 || ~3.0.1 || 5.0.0', '1.0.0beta', true],
['^0.1.0 || ~3.0.1 || 5.0.0', '5.0.0-0', true],
['^0.1.0 || ~3.0.1 || >4 <=5.0.0', '3.5.0'],
['^1.0.0alpha', '1.0.0beta', true],
['~1.0.0alpha', '1.0.0beta', true],
['^1.0.0-alpha', '1.0.0beta', true],
['~1.0.0-alpha', '1.0.0beta', true],
['^1.0.0-alpha', '1.0.0-beta'],
['~1.0.0-alpha', '1.0.0-beta'],
['=0.1.0', '1.0.0']
].forEach(function(tuple) {
var range = tuple[0];
var version = tuple[1];
var loose = tuple[2] || false;
var msg = '!ltr(' + version + ', ' + range + ', ' + loose + ')';
t.notOk(ltr(version, range, loose), msg);
});
t.end();
});

View File

@ -0,0 +1,72 @@
var tap = require('tap');
var test = tap.test;
var semver = require('../semver.js');
test('\nmajor tests', function(t) {
// [range, version]
// Version should be detectable despite extra characters
[
['1.2.3', 1],
[' 1.2.3 ', 1],
[' 2.2.3-4 ', 2],
[' 3.2.3-pre ', 3],
['v5.2.3', 5],
[' v8.2.3 ', 8],
['\t13.2.3', 13],
['=21.2.3', 21, true],
['v=34.2.3', 34, true]
].forEach(function(tuple) {
var range = tuple[0];
var version = tuple[1];
var loose = tuple[2] || false;
var msg = 'major(' + range + ') = ' + version;
t.equal(semver.major(range, loose), version, msg);
});
t.end();
});
test('\nminor tests', function(t) {
// [range, version]
// Version should be detectable despite extra characters
[
['1.1.3', 1],
[' 1.1.3 ', 1],
[' 1.2.3-4 ', 2],
[' 1.3.3-pre ', 3],
['v1.5.3', 5],
[' v1.8.3 ', 8],
['\t1.13.3', 13],
['=1.21.3', 21, true],
['v=1.34.3', 34, true]
].forEach(function(tuple) {
var range = tuple[0];
var version = tuple[1];
var loose = tuple[2] || false;
var msg = 'minor(' + range + ') = ' + version;
t.equal(semver.minor(range, loose), version, msg);
});
t.end();
});
test('\npatch tests', function(t) {
// [range, version]
// Version should be detectable despite extra characters
[
['1.2.1', 1],
[' 1.2.1 ', 1],
[' 1.2.2-4 ', 2],
[' 1.2.3-pre ', 3],
['v1.2.5', 5],
[' v1.2.8 ', 8],
['\t1.2.13', 13],
['=1.2.21', 21, true],
['v=1.2.34', 34, true]
].forEach(function(tuple) {
var range = tuple[0];
var version = tuple[1];
var loose = tuple[2] || false;
var msg = 'patch(' + range + ') = ' + version;
t.equal(semver.patch(range, loose), version, msg);
});
t.end();
});

View File

@ -0,0 +1,19 @@
var tap = require('tap');
var test = tap.test;
test('no module system', function(t) {
var fs = require('fs');
var vm = require('vm');
var head = fs.readFileSync(require.resolve('../head.js.txt'), 'utf8');
var src = fs.readFileSync(require.resolve('../'), 'utf8');
var foot = fs.readFileSync(require.resolve('../foot.js.txt'), 'utf8');
vm.runInThisContext(head + src + foot, 'semver.js');
// just some basic poking to see if it did some stuff
t.type(global.semver, 'object');
t.type(global.semver.SemVer, 'function');
t.type(global.semver.Range, 'function');
t.ok(global.semver.satisfies('1.2.3', '1.2'));
t.end();
});

82
express-server/node_modules/pg/package.json generated vendored Normal file
View File

@ -0,0 +1,82 @@
{
"_from": "pg",
"_id": "pg@7.6.0",
"_inBundle": false,
"_integrity": "sha512-INUjsobS7O0Slad6fVlSSSVpMd5wozwtdSrWL5/JfEGYCWtPwgka0uQOf2KCo7QbWUmwefcuNQtzijeztDquQg==",
"_location": "/pg",
"_phantomChildren": {},
"_requested": {
"type": "tag",
"registry": true,
"raw": "pg",
"name": "pg",
"escapedName": "pg",
"rawSpec": "",
"saveSpec": null,
"fetchSpec": "latest"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/pg/-/pg-7.6.0.tgz",
"_shasum": "0c9ecaf0ce6f3c7e3c68ce8f621df79e741a89e3",
"_spec": "pg",
"_where": "D:\\5CHITM\\Diplomarbeit\\smart-shopper\\SmartShopper\\express-server",
"author": {
"name": "Brian Carlson",
"email": "brian.m.carlson@gmail.com"
},
"bugs": {
"url": "https://github.com/brianc/node-postgres/issues"
},
"bundleDependencies": false,
"dependencies": {
"buffer-writer": "1.0.1",
"packet-reader": "0.3.1",
"pg-connection-string": "0.1.3",
"pg-pool": "~2.0.3",
"pg-types": "~1.12.1",
"pgpass": "1.x",
"semver": "4.3.2"
},
"deprecated": false,
"description": "PostgreSQL client - pure javascript & libpq with the same API",
"devDependencies": {
"async": "0.9.0",
"bluebird": "3.5.2",
"co": "4.6.0",
"eslint": "^4.19.1",
"eslint-config-standard": "^11.0.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^3.1.0",
"pg-copy-streams": "0.3.0"
},
"engines": {
"node": ">= 4.5.0"
},
"homepage": "http://github.com/brianc/node-postgres",
"keywords": [
"database",
"libpq",
"pg",
"postgre",
"postgres",
"postgresql",
"rdbms"
],
"license": "MIT",
"main": "./lib",
"minNativeVersion": "2.0.0",
"name": "pg",
"repository": {
"type": "git",
"url": "git://github.com/brianc/node-postgres.git"
},
"scripts": {
"test": "make test-all"
},
"version": "7.6.0"
}