mirror of https://gitee.com/bigwinds/arangodb
Updated npm deps.
This commit is contained in:
parent
be913280f2
commit
6170c19c56
|
@ -1,3 +1,17 @@
|
|||
2.3.0 / 2015-04-26
|
||||
==================
|
||||
|
||||
* Merge pull request #423 from ehntoo/patch-1
|
||||
* Merge pull request #422 from ljharb/fix_descriptor_tests
|
||||
* Fix a small bug in the .null assertion docs
|
||||
* Use a regex to account for property ordering issues across engines.
|
||||
* Add `make test-firefox`
|
||||
* Merge pull request #417 from astorije/astorije/minimalist-typo
|
||||
* Remove trailing whitespaces
|
||||
* Fix super minor typo in an example
|
||||
* Merge pull request #408 from ljharb/enumerableProperty
|
||||
* Add `ownPropertyDescriptor` assertion.
|
||||
|
||||
2.2.0 / 2015-03-26
|
||||
==================
|
||||
|
||||
|
|
|
@ -25,82 +25,85 @@ Chai offers a robust Plugin architecture for extending Chai's assertions and int
|
|||
### Contributors
|
||||
|
||||
project : chai
|
||||
repo age : 3 years, 3 months
|
||||
active : 232 days
|
||||
commits : 879
|
||||
repo age : 3 years, 5 months
|
||||
active : 244 days
|
||||
commits : 900
|
||||
files : 59
|
||||
authors :
|
||||
555 Jake Luer 63.1%
|
||||
79 Veselin Todorov 9.0%
|
||||
43 Domenic Denicola 4.9%
|
||||
41 Keith Cirkel 4.7%
|
||||
555 Jake Luer 61.7%
|
||||
79 Veselin Todorov 8.8%
|
||||
52 Keith Cirkel 5.8%
|
||||
43 Domenic Denicola 4.8%
|
||||
14 Joshua Perry 1.6%
|
||||
8 Chris Polis 0.9%
|
||||
6 Ruben Verborgh 0.7%
|
||||
6 Ian Zamojc 0.7%
|
||||
5 leider 0.6%
|
||||
5 George Kats 0.6%
|
||||
5 leider 0.6%
|
||||
5 Scott Nonnenberg 0.6%
|
||||
5 Jo Liss 0.6%
|
||||
5 Juliusz Gonera 0.6%
|
||||
4 Veselin 0.5%
|
||||
4 Nick Heiner 0.5%
|
||||
4 David da Silva 0.5%
|
||||
4 Chris Jones 0.5%
|
||||
4 josher19 0.5%
|
||||
4 John Firebaugh 0.5%
|
||||
4 Max Edmands 0.5%
|
||||
4 charlierudolph 0.5%
|
||||
5 Jo Liss 0.6%
|
||||
4 Jérémie Astori 0.4%
|
||||
4 John Firebaugh 0.4%
|
||||
4 charlierudolph 0.4%
|
||||
4 Veselin 0.4%
|
||||
4 Chris Jones 0.4%
|
||||
4 Nick Heiner 0.4%
|
||||
4 Max Edmands 0.4%
|
||||
4 David da Silva 0.4%
|
||||
4 Kaito Udagawa 0.4%
|
||||
4 josher19 0.4%
|
||||
3 Jordan Harband 0.3%
|
||||
3 Ryunosuke SATO 0.3%
|
||||
3 Jake Rosoman 0.3%
|
||||
3 Duncan Beevers 0.3%
|
||||
3 Jason Karns 0.3%
|
||||
3 Jeff Barczewski 0.3%
|
||||
3 Andrei Neculau 0.3%
|
||||
3 Duncan Beevers 0.3%
|
||||
3 Jake Rosoman 0.3%
|
||||
2 Teddy Cross 0.2%
|
||||
2 eldritch fossicker 0.2%
|
||||
2 Bartvds 0.2%
|
||||
2 Edwin Shao 0.2%
|
||||
2 Gregg Lind 0.2%
|
||||
2 Roman Masek 0.2%
|
||||
2 Jérémie Astori 0.2%
|
||||
2 Jakub Nešetřil 0.2%
|
||||
2 eldritch fossicker 0.2%
|
||||
1 Adam Hull 0.1%
|
||||
1 toastynerd 0.1%
|
||||
1 Anand Patil 0.1%
|
||||
1 Benjamin Horsleben 0.1%
|
||||
1 Brandon Payton 0.1%
|
||||
1 Chasen Le Hara 0.1%
|
||||
1 Chris Connelly 0.1%
|
||||
1 Chris Thompson 0.1%
|
||||
1 Christopher Hiller 0.1%
|
||||
1 Chun-Yi 0.1%
|
||||
1 DD 0.1%
|
||||
1 Danilo Vaz 0.1%
|
||||
1 Dido Arellano 0.1%
|
||||
1 Doug Neiner 0.1%
|
||||
1 Jeff Welch 0.1%
|
||||
2 Roman Masek 0.2%
|
||||
2 Teddy Cross 0.2%
|
||||
1 Jesse McCarthy 0.1%
|
||||
1 Julien Wajsberg 0.1%
|
||||
1 Doug Neiner 0.1%
|
||||
1 Dido Arellano 0.1%
|
||||
1 Kilian Ciuffolo 0.1%
|
||||
1 Luís Cardoso 0.1%
|
||||
1 Martin Middel 0.1%
|
||||
1 Mathias Schreck 0.1%
|
||||
1 Danilo Vaz 0.1%
|
||||
1 Michael Lange 0.1%
|
||||
1 Mitchell Johnson 0.1%
|
||||
1 DD 0.1%
|
||||
1 Niklas Närhinen 0.1%
|
||||
1 Paul Miller 0.1%
|
||||
1 Refael Ackermann 0.1%
|
||||
1 shinnn 0.1%
|
||||
1 Chun-Yi 0.1%
|
||||
1 Christopher Hiller 0.1%
|
||||
1 Sasha Koss 0.1%
|
||||
1 Chris Thompson 0.1%
|
||||
1 toastynerd 0.1%
|
||||
1 Chris Connelly 0.1%
|
||||
1 Chasen Le Hara 0.1%
|
||||
1 Victor Costan 0.1%
|
||||
1 Vinay Pulim 0.1%
|
||||
1 Virginie BARDALES 0.1%
|
||||
1 Vlad GURDIGA 0.1%
|
||||
1 Brandon Payton 0.1%
|
||||
1 Adam Hull 0.1%
|
||||
1 ericdouglas 0.1%
|
||||
1 Benjamin Horsleben 0.1%
|
||||
1 laconbass 0.1%
|
||||
1 Anand Patil 0.1%
|
||||
1 mohayonao 0.1%
|
||||
1 piecioshka 0.1%
|
||||
1 root 0.1%
|
||||
1 shinnn 0.1%
|
||||
1 Julien Wajsberg 0.1%
|
||||
1 Jeff Welch 0.1%
|
||||
|
||||
## License
|
||||
|
||||
|
|
|
@ -1,5 +1,36 @@
|
|||
# Release Notes
|
||||
|
||||
## 2.3.0 / 2015-04-26
|
||||
|
||||
Added `ownPropertyDescriptor` assertion:
|
||||
|
||||
```js
|
||||
expect('test').to.have.ownPropertyDescriptor('length');
|
||||
expect('test').to.have.ownPropertyDescriptor('length', { enumerable: false, configurable: false, writable: false, value: 4 });
|
||||
expect('test').not.to.have.ownPropertyDescriptor('length', { enumerable: false, configurable: false, writable: false, value: 3 });
|
||||
expect('test').ownPropertyDescriptor('length').to.have.property('enumerable', false);
|
||||
expect('test').ownPropertyDescriptor('length').to.have.keys('value');
|
||||
```
|
||||
|
||||
### Community Contributions
|
||||
|
||||
#### Code Features & Fixes
|
||||
|
||||
* [#408](https://github.com/chaijs/chai/pull/408) Add `ownPropertyDescriptor`
|
||||
assertion.
|
||||
By [@ljharb](https://github.com/ljharb)
|
||||
* [#422](https://github.com/chaijs/chai/pull/422) Improve ownPropertyDescriptor
|
||||
tests.
|
||||
By [@ljharb](https://github.com/ljharb)
|
||||
|
||||
#### Documentation fixes
|
||||
|
||||
* [#417](https://github.com/chaijs/chai/pull/417) Fix documentation typo
|
||||
By [@astorije](https://github.com/astorije)
|
||||
* [#423](https://github.com/chaijs/chai/pull/423) Fix inconsistency in docs.
|
||||
By [@ehntoo](https://github.com/ehntoo)
|
||||
|
||||
|
||||
## 2.2.0 / 2015-03-26
|
||||
|
||||
Deep property strings can now be escaped using `\\` - for example:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "chai",
|
||||
"version": "2.2.0",
|
||||
"version": "2.3.0",
|
||||
"description": "BDD/TDD assertion library for node.js and the browser. Test framework agnostic.",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
|
|
|
@ -678,7 +678,7 @@ var used = []
|
|||
* Chai version
|
||||
*/
|
||||
|
||||
exports.version = '2.2.0';
|
||||
exports.version = '2.3.0';
|
||||
|
||||
/*!
|
||||
* Assertion Error
|
||||
|
@ -1051,7 +1051,7 @@ module.exports = function (chai, _) {
|
|||
* ### .any
|
||||
*
|
||||
* Sets the `any` flag, (opposite of the `all` flag)
|
||||
* later used in the `keys` assertion.
|
||||
* later used in the `keys` assertion.
|
||||
*
|
||||
* expect(foo).to.have.any.keys('bar', 'baz');
|
||||
*
|
||||
|
@ -1068,7 +1068,7 @@ module.exports = function (chai, _) {
|
|||
/**
|
||||
* ### .all
|
||||
*
|
||||
* Sets the `all` flag (opposite of the `any` flag)
|
||||
* Sets the `all` flag (opposite of the `any` flag)
|
||||
* later used by the `keys` assertion.
|
||||
*
|
||||
* expect(foo).to.have.all.keys('bar', 'baz');
|
||||
|
@ -1249,7 +1249,7 @@ module.exports = function (chai, _) {
|
|||
* Asserts that the target is `null`.
|
||||
*
|
||||
* expect(null).to.be.null;
|
||||
* expect(undefined).not.to.be.null;
|
||||
* expect(undefined).to.not.be.null;
|
||||
*
|
||||
* @name null
|
||||
* @api public
|
||||
|
@ -1725,7 +1725,7 @@ module.exports = function (chai, _) {
|
|||
* green: { tea: 'matcha' }
|
||||
* , teas: [ 'chai', 'matcha', { tea: 'konacha' } ]
|
||||
* };
|
||||
*
|
||||
*
|
||||
* expect(deepObj).to.have.deep.property('green.tea', 'matcha');
|
||||
* expect(deepObj).to.have.deep.property('teas[1]', 'matcha');
|
||||
* expect(deepObj).to.have.deep.property('teas[2].tea', 'konacha');
|
||||
|
@ -1846,6 +1846,55 @@ module.exports = function (chai, _) {
|
|||
Assertion.addMethod('ownProperty', assertOwnProperty);
|
||||
Assertion.addMethod('haveOwnProperty', assertOwnProperty);
|
||||
|
||||
/**
|
||||
* ### .ownPropertyDescriptor(name[, descriptor[, message]])
|
||||
*
|
||||
* Asserts that the target has an own property descriptor `name`, that optionally matches `descriptor`.
|
||||
*
|
||||
* expect('test').to.have.ownPropertyDescriptor('length');
|
||||
* expect('test').to.have.ownPropertyDescriptor('length', { enumerable: false, configurable: false, writable: false, value: 4 });
|
||||
* expect('test').not.to.have.ownPropertyDescriptor('length', { enumerable: false, configurable: false, writable: false, value: 3 });
|
||||
* expect('test').ownPropertyDescriptor('length').to.have.property('enumerable', false);
|
||||
* expect('test').ownPropertyDescriptor('length').to.have.keys('value');
|
||||
*
|
||||
* @name ownPropertyDescriptor
|
||||
* @alias haveOwnPropertyDescriptor
|
||||
* @param {String} name
|
||||
* @param {Object} descriptor _optional_
|
||||
* @param {String} message _optional_
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function assertOwnPropertyDescriptor (name, descriptor, msg) {
|
||||
if (typeof descriptor === 'string') {
|
||||
msg = descriptor;
|
||||
descriptor = null;
|
||||
}
|
||||
if (msg) flag(this, 'message', msg);
|
||||
var obj = flag(this, 'object');
|
||||
var actualDescriptor = Object.getOwnPropertyDescriptor(Object(obj), name);
|
||||
if (actualDescriptor && descriptor) {
|
||||
this.assert(
|
||||
_.eql(descriptor, actualDescriptor)
|
||||
, 'expected the own property descriptor for ' + _.inspect(name) + ' on #{this} to match ' + _.inspect(descriptor) + ', got ' + _.inspect(actualDescriptor)
|
||||
, 'expected the own property descriptor for ' + _.inspect(name) + ' on #{this} to not match ' + _.inspect(descriptor)
|
||||
, descriptor
|
||||
, actualDescriptor
|
||||
, true
|
||||
);
|
||||
} else {
|
||||
this.assert(
|
||||
actualDescriptor
|
||||
, 'expected #{this} to have an own property descriptor for ' + _.inspect(name)
|
||||
, 'expected #{this} to not have an own property descriptor for ' + _.inspect(name)
|
||||
);
|
||||
}
|
||||
flag(this, 'object', actualDescriptor);
|
||||
}
|
||||
|
||||
Assertion.addMethod('ownPropertyDescriptor', assertOwnPropertyDescriptor);
|
||||
Assertion.addMethod('haveOwnPropertyDescriptor', assertOwnPropertyDescriptor);
|
||||
|
||||
/**
|
||||
* ### .length(value)
|
||||
*
|
||||
|
@ -1947,30 +1996,30 @@ module.exports = function (chai, _) {
|
|||
* ### .keys(key1, [key2], [...])
|
||||
*
|
||||
* Asserts that the target contains any or all of the passed-in keys.
|
||||
* Use in combination with `any`, `all`, `contains`, or `have` will affect
|
||||
* Use in combination with `any`, `all`, `contains`, or `have` will affect
|
||||
* what will pass.
|
||||
*
|
||||
* When used in conjunction with `any`, at least one key that is passed
|
||||
* in must exist in the target object. This is regardless whether or not
|
||||
*
|
||||
* When used in conjunction with `any`, at least one key that is passed
|
||||
* in must exist in the target object. This is regardless whether or not
|
||||
* the `have` or `contain` qualifiers are used. Note, either `any` or `all`
|
||||
* should be used in the assertion. If neither are used, the assertion is
|
||||
* defaulted to `all`.
|
||||
*
|
||||
* When both `all` and `contain` are used, the target object must have at
|
||||
*
|
||||
* When both `all` and `contain` are used, the target object must have at
|
||||
* least all of the passed-in keys but may have more keys not listed.
|
||||
*
|
||||
*
|
||||
* When both `all` and `have` are used, the target object must both contain
|
||||
* all of the passed-in keys AND the number of keys in the target object must
|
||||
* match the number of keys passed in (in other words, a target object must
|
||||
* match the number of keys passed in (in other words, a target object must
|
||||
* have all and only all of the passed-in keys).
|
||||
*
|
||||
*
|
||||
* expect({ foo: 1, bar: 2 }).to.have.any.keys('foo', 'baz');
|
||||
* expect({ foo: 1, bar: 2 }).to.have.any.keys('foo');
|
||||
* expect({ foo: 1, bar: 2 }).to.contain.any.keys('bar', 'baz');
|
||||
* expect({ foo: 1, bar: 2 }).to.contain.any.keys(['foo']);
|
||||
* expect({ foo: 1, bar: 2 }).to.contain.any.keys({'foo': 6});
|
||||
* expect({ foo: 1, bar: 2 }).to.have.all.keys(['bar', 'foo']);
|
||||
* expect({ foo: 1, bar: 2 }).to.have.all.keys({'bar': 6, 'foo', 7});
|
||||
* expect({ foo: 1, bar: 2 }).to.have.all.keys({'bar': 6, 'foo': 7});
|
||||
* expect({ foo: 1, bar: 2, baz: 3 }).to.contain.all.keys(['bar', 'foo']);
|
||||
* expect({ foo: 1, bar: 2, baz: 3 }).to.contain.all.keys([{'bar': 6}}]);
|
||||
*
|
||||
|
|
|
@ -11,7 +11,7 @@ var used = []
|
|||
* Chai version
|
||||
*/
|
||||
|
||||
exports.version = '2.2.0';
|
||||
exports.version = '2.3.0';
|
||||
|
||||
/*!
|
||||
* Assertion Error
|
||||
|
|
|
@ -50,7 +50,5 @@
|
|||
],
|
||||
"directories": {},
|
||||
"_shasum": "c7f85438fdd466bc7ca16ab90c81513797a5d23b",
|
||||
"_resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.0.0.tgz",
|
||||
"readme": "ERROR: No README data found!",
|
||||
"homepage": "https://github.com/chaijs/assertion-error"
|
||||
"_resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.0.0.tgz"
|
||||
}
|
||||
|
|
|
@ -52,7 +52,5 @@
|
|||
],
|
||||
"directories": {},
|
||||
"_shasum": "0ba5ec2a885640e470ea4e8505971900dac58822",
|
||||
"_resolved": "https://registry.npmjs.org/type-detect/-/type-detect-0.1.1.tgz",
|
||||
"readme": "ERROR: No README data found!",
|
||||
"homepage": "https://github.com/chaijs/type-detect"
|
||||
"_resolved": "https://registry.npmjs.org/type-detect/-/type-detect-0.1.1.tgz"
|
||||
}
|
||||
|
|
|
@ -37,8 +37,6 @@
|
|||
"mocha-lcov-reporter": "0.0.1",
|
||||
"simple-assert": "*"
|
||||
},
|
||||
"readme": "# deep-eql [](https://travis-ci.org/chaijs/deep-eql) [](https://coveralls.io/r/chaijs/deep-eql?branch=master)\n\n> Improved deep equality testing for Node.js and the browser.\n\n## Installation\n\n### Node.js\n\n`deep-eql` is available on [npm](http://npmjs.org).\n\n $ npm install deep-eql\n\n### Component\n\n`deep-eql` is available as a [component](https://github.com/component/component).\n\n $ component install chaijs/deep-eql\n\n## Usage\n\n### Rules\n\n- Strict equality for non-traversable nodes according to [egal](http://wiki.ecmascript.org/doku.php?id=harmony:egal).\n - `eql(NaN, NaN).should.be.true;`\n - `eql(-0, +0).should.be.false;`\n- Arguments are not Arrays:\n - `eql([], arguments).should.be.false;`\n - `eql([], Array.prototype.slice.call(arguments)).should.be.true;`\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2013 Jake Luer <jake@alogicalparadox.com>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n",
|
||||
"readmeFilename": "README.md",
|
||||
"bugs": {
|
||||
"url": "https://github.com/chaijs/deep-eql/issues"
|
||||
},
|
||||
|
@ -61,6 +59,5 @@
|
|||
],
|
||||
"directories": {},
|
||||
"_shasum": "ef558acab8de25206cd713906d74e56930eb69f2",
|
||||
"_resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-0.1.3.tgz",
|
||||
"homepage": "https://github.com/chaijs/deep-eql"
|
||||
"_resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-0.1.3.tgz"
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
"email": "john.firebaugh@gmail.com"
|
||||
}
|
||||
],
|
||||
"version": "2.2.0",
|
||||
"version": "2.3.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/chaijs/chai"
|
||||
|
@ -58,29 +58,34 @@
|
|||
"karma-mocha": "*",
|
||||
"karma-sauce-launcher": "0.2.x",
|
||||
"karma-phantomjs-launcher": "0.1.1",
|
||||
"karma-firefox-launcher": "^0.1.4",
|
||||
"mocha": "1.21.x",
|
||||
"istanbul": "0.2.x"
|
||||
},
|
||||
"gitHead": "57df3888f66c4b34923ce8576aa93855a0ec2f75",
|
||||
"_id": "chai@2.2.0",
|
||||
"_shasum": "d21135623bd393ad4702d94536eca482ad78d01d",
|
||||
"_from": "chai@*",
|
||||
"_npmVersion": "1.4.28",
|
||||
"gitHead": "3de55026458ace296df354757361953ec1949859",
|
||||
"_id": "chai@2.3.0",
|
||||
"_shasum": "8a2f6a34748da801090fd73287b2aa739a4e909a",
|
||||
"_from": "chai@2.3.0",
|
||||
"_npmVersion": "2.7.6",
|
||||
"_nodeVersion": "0.10.36",
|
||||
"_npmUser": {
|
||||
"name": "jakeluer",
|
||||
"email": "jake@alogicalparadox.com"
|
||||
"name": "chaijs",
|
||||
"email": "chaijs@keithcirkel.co.uk"
|
||||
},
|
||||
"dist": {
|
||||
"shasum": "8a2f6a34748da801090fd73287b2aa739a4e909a",
|
||||
"tarball": "http://registry.npmjs.org/chai/-/chai-2.3.0.tgz"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "jakeluer",
|
||||
"email": "jake.luer@incatern.com"
|
||||
"email": "jake@alogicalparadox.com"
|
||||
},
|
||||
{
|
||||
"name": "chaijs",
|
||||
"email": "chaijs@keithcirkel.co.uk"
|
||||
}
|
||||
],
|
||||
"dist": {
|
||||
"shasum": "d21135623bd393ad4702d94536eca482ad78d01d",
|
||||
"tarball": "http://registry.npmjs.org/chai/-/chai-2.2.0.tgz"
|
||||
},
|
||||
"directories": {},
|
||||
"_resolved": "https://registry.npmjs.org/chai/-/chai-2.2.0.tgz",
|
||||
"readme": "ERROR: No README data found!"
|
||||
"_resolved": "https://registry.npmjs.org/chai/-/chai-2.3.0.tgz"
|
||||
}
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
{
|
||||
} } {
|
||||
{ { } }
|
||||
} }{ {
|
||||
{ }{ } } _____ __ __
|
||||
{ }{ }{ { } / ____| / _|/ _|
|
||||
.- { { } { }} -. | | ___ | |_| |_ ___ ___
|
||||
( { } { } { } } ) | | / _ \| _| _/ _ \/ _ \
|
||||
|`-..________ ..-'| | |___| (_) | | | || __/ __/
|
||||
| | \_____\___/|_| |_| \___|\___|
|
||||
| ;--.
|
||||
| (__ \ _____ _ _
|
||||
| | ) ) / ____| (_) | |
|
||||
| |/ / | (___ ___ _ __ _ _ __ | |_
|
||||
| ( / \___ \ / __| '__| | '_ \| __|
|
||||
| |/ ____) | (__| | | | |_) | |_
|
||||
| | |_____/ \___|_| |_| .__/ \__|
|
||||
`-.._________..-' | |
|
||||
|_|
|
||||
|
||||
|
||||
CoffeeScript is a little language that compiles into JavaScript.
|
||||
|
||||
If you have the Node Package Manager installed:
|
||||
npm install -g coffee-script
|
||||
(Leave off the -g if you don't wish to install globally.)
|
||||
|
||||
Or, if you don't wish to use npm:
|
||||
sudo bin/cake install
|
||||
|
||||
Execute a script:
|
||||
coffee /path/to/script.coffee
|
||||
|
||||
Compile a script:
|
||||
coffee -c /path/to/script.coffee
|
||||
|
||||
For documentation, usage, and examples, see:
|
||||
http://coffeescript.org/
|
||||
|
||||
To suggest a feature, report a bug, or general discussion:
|
||||
http://github.com/jashkenas/coffeescript/issues/
|
||||
|
||||
If you'd like to chat, drop by #coffeescript on Freenode IRC,
|
||||
or on webchat.freenode.net.
|
||||
|
||||
The source repository:
|
||||
git://github.com/jashkenas/coffeescript.git
|
||||
|
||||
Top 100 contributors are listed here:
|
||||
http://github.com/jashkenas/coffeescript/contributors
|
|
@ -57,4 +57,6 @@ If you'd like to chat, drop by #coffeescript on Freenode IRC.
|
|||
|
||||
The source repository: https://github.com/jashkenas/coffeescript.git
|
||||
|
||||
Changelog: http://coffeescript.org/#changelog
|
||||
|
||||
Our lovely and talented contributors are listed here: http://github.com/jashkenas/coffeescript/contributors
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "coffee-script",
|
||||
"version": "1.9.1",
|
||||
"version": "1.9.3",
|
||||
"main": [
|
||||
"lib/coffee-script/coffee-script.js"
|
||||
],
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.3
|
||||
(function() {
|
||||
var CoffeeScript, compile, runScripts,
|
||||
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
||||
|
@ -104,12 +104,13 @@
|
|||
}
|
||||
};
|
||||
fn = function(script, i) {
|
||||
var options;
|
||||
var options, source;
|
||||
options = {
|
||||
literate: script.type === coffeetypes[1]
|
||||
};
|
||||
if (script.src) {
|
||||
return CoffeeScript.load(script.src, function(param) {
|
||||
source = script.src || script.getAttribute('data-src');
|
||||
if (source) {
|
||||
return CoffeeScript.load(source, function(param) {
|
||||
coffees[i] = param;
|
||||
return execute();
|
||||
}, options, true);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.3
|
||||
(function() {
|
||||
var CoffeeScript, cakefileDirectory, fatalError, fs, helpers, missingTask, oparse, options, optparse, path, printTasks, switches, tasks;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.3
|
||||
(function() {
|
||||
var Lexer, SourceMap, base, compile, ext, formatSourcePosition, fs, getSourceMap, helpers, i, len, lexer, parser, path, ref, sourceMaps, vm, withPrettyErrors,
|
||||
hasProp = {}.hasOwnProperty,
|
||||
|
@ -18,7 +18,7 @@
|
|||
|
||||
SourceMap = require('./sourcemap');
|
||||
|
||||
exports.VERSION = '1.9.1';
|
||||
exports.VERSION = '1.9.3';
|
||||
|
||||
exports.FILE_EXTENSIONS = ['.coffee', '.litcoffee', '.coffee.md'];
|
||||
|
||||
|
@ -34,6 +34,9 @@
|
|||
return fn.call(this, code, options);
|
||||
} catch (_error) {
|
||||
err = _error;
|
||||
if (typeof code !== 'string') {
|
||||
throw err;
|
||||
}
|
||||
throw helpers.updateSyntaxError(err, code, options.filename);
|
||||
}
|
||||
};
|
||||
|
@ -71,7 +74,7 @@
|
|||
for (i = 0, len = fragments.length; i < len; i++) {
|
||||
fragment = fragments[i];
|
||||
if (options.sourceMap) {
|
||||
if (fragment.locationData) {
|
||||
if (fragment.locationData && !/^[;\s]*$/.test(fragment.code)) {
|
||||
map.add([fragment.locationData.first_line, fragment.locationData.first_column], [currentLine, currentColumn], {
|
||||
noReplace: true
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.3
|
||||
(function() {
|
||||
var BANNER, CoffeeScript, EventEmitter, SWITCHES, compileJoin, compileOptions, compilePath, compileScript, compileStdio, exec, findDirectoryIndex, forkNode, fs, helpers, hidden, joinTimeout, jsToSources, mkdirp, notSources, optionParser, optparse, opts, outputPath, parseOptions, path, printLine, printTokens, printWarn, ref, removeSource, removeSourceDir, silentUnlink, sourceCode, sources, spawn, timeLog, usage, useWinPathSep, version, wait, watch, watchDir, watchedDirs, writeJs,
|
||||
var BANNER, CoffeeScript, EventEmitter, SWITCHES, compileJoin, compileOptions, compilePath, compileScript, compileStdio, exec, findDirectoryIndex, forkNode, fs, helpers, hidden, joinTimeout, makePrelude, mkdirp, notSources, optionParser, optparse, opts, outputPath, parseOptions, path, printLine, printTokens, printWarn, ref, removeSource, removeSourceDir, silentUnlink, sourceCode, sources, spawn, timeLog, usage, useWinPathSep, version, wait, watch, watchDir, watchedDirs, writeJs,
|
||||
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
||||
|
||||
fs = require('fs');
|
||||
|
@ -35,7 +35,7 @@
|
|||
|
||||
BANNER = 'Usage: coffee [options] path/to/script.coffee -- [args]\n\nIf called without options, `coffee` will run your script.';
|
||||
|
||||
SWITCHES = [['-b', '--bare', 'compile without a top-level function wrapper'], ['-c', '--compile', 'compile to JavaScript and save as .js files'], ['-e', '--eval', 'pass a string from the command line as input'], ['-h', '--help', 'display this help message'], ['-i', '--interactive', 'run an interactive CoffeeScript REPL'], ['-j', '--join [FILE]', 'concatenate the source CoffeeScript before compiling'], ['-m', '--map', 'generate source map and save as .js.map files'], ['-n', '--nodes', 'print out the parse tree that the parser produces'], ['--nodejs [ARGS]', 'pass options directly to the "node" binary'], ['--no-header', 'suppress the "Generated by" header'], ['-o', '--output [DIR]', 'set the output directory for compiled JavaScript'], ['-p', '--print', 'print out the compiled JavaScript'], ['-s', '--stdio', 'listen for and compile scripts over stdio'], ['-l', '--literate', 'treat stdio as literate style coffee-script'], ['-t', '--tokens', 'print out the tokens that the lexer/rewriter produce'], ['-v', '--version', 'display the version number'], ['-w', '--watch', 'watch scripts for changes and rerun commands']];
|
||||
SWITCHES = [['-b', '--bare', 'compile without a top-level function wrapper'], ['-c', '--compile', 'compile to JavaScript and save as .js files'], ['-e', '--eval', 'pass a string from the command line as input'], ['-h', '--help', 'display this help message'], ['-i', '--interactive', 'run an interactive CoffeeScript REPL'], ['-j', '--join [FILE]', 'concatenate the source CoffeeScript before compiling'], ['-m', '--map', 'generate source map and save as .js.map files'], ['-n', '--nodes', 'print out the parse tree that the parser produces'], ['--nodejs [ARGS]', 'pass options directly to the "node" binary'], ['--no-header', 'suppress the "Generated by" header'], ['-o', '--output [DIR]', 'set the output directory for compiled JavaScript'], ['-p', '--print', 'print out the compiled JavaScript'], ['-r', '--require [MODULE*]', 'require the given module before eval or REPL'], ['-s', '--stdio', 'listen for and compile scripts over stdio'], ['-l', '--literate', 'treat stdio as literate style coffee-script'], ['-t', '--tokens', 'print out the tokens that the lexer/rewriter produce'], ['-v', '--version', 'display the version number'], ['-w', '--watch', 'watch scripts for changes and rerun commands']];
|
||||
|
||||
opts = {};
|
||||
|
||||
|
@ -49,14 +49,16 @@
|
|||
|
||||
optionParser = null;
|
||||
|
||||
jsToSources = {};
|
||||
|
||||
exports.run = function() {
|
||||
var i, len, literals, ref1, replCliOpts, results, source;
|
||||
parseOptions();
|
||||
replCliOpts = {
|
||||
useGlobal: true
|
||||
};
|
||||
if (opts.require) {
|
||||
opts.prelude = makePrelude(opts.require);
|
||||
}
|
||||
replCliOpts.prelude = opts.prelude;
|
||||
if (opts.nodejs) {
|
||||
return forkNode();
|
||||
}
|
||||
|
@ -98,6 +100,17 @@
|
|||
return results;
|
||||
};
|
||||
|
||||
makePrelude = function(requires) {
|
||||
return requires.map(function(module) {
|
||||
var _, match, name;
|
||||
if (match = module.match(/^(.*)=(.*)$/)) {
|
||||
_ = match[0], name = match[1], module = match[2];
|
||||
}
|
||||
name || (name = helpers.baseFileName(module, true, useWinPathSep));
|
||||
return name + " = require('" + module + "')";
|
||||
}).join(';');
|
||||
};
|
||||
|
||||
compilePath = function(source, topLevel, base) {
|
||||
var code, err, file, files, i, len, results, stats;
|
||||
if (indexOf.call(sources, source) >= 0 || watchedDirs[source] || !topLevel && (notSources[source] || hidden(source))) {
|
||||
|
@ -205,6 +218,9 @@
|
|||
return printLine(CoffeeScript.nodes(t.input, t.options).toString().trim());
|
||||
} else if (o.run) {
|
||||
CoffeeScript.register();
|
||||
if (opts.prelude) {
|
||||
CoffeeScript["eval"](opts.prelude, t.options);
|
||||
}
|
||||
return CoffeeScript.run(t.input, t.options);
|
||||
} else if (o.join && t.file !== o.join) {
|
||||
if (helpers.isLiterate(file)) {
|
||||
|
@ -468,13 +484,6 @@
|
|||
}
|
||||
sourceMapPath = outputPath(sourcePath, base, ".js.map");
|
||||
jsDir = path.dirname(jsPath);
|
||||
if (jsPath in jsToSources) {
|
||||
printLine("Error: The two following source files have the same output file:");
|
||||
printLine(" " + jsToSources[jsPath]);
|
||||
printLine(" " + sourcePath);
|
||||
process.exit(1);
|
||||
}
|
||||
jsToSources[jsPath] = sourcePath;
|
||||
compile = function() {
|
||||
if (opts.compile) {
|
||||
if (js.length <= 0) {
|
||||
|
@ -582,7 +591,7 @@
|
|||
p = spawn(process.execPath, nodeArgs.concat(args), {
|
||||
cwd: process.cwd(),
|
||||
env: process.env,
|
||||
customFds: [0, 1, 2]
|
||||
stdio: [0, 1, 2]
|
||||
});
|
||||
return p.on('exit', function(code) {
|
||||
return process.exit(code);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.3
|
||||
(function() {
|
||||
var Parser, alt, alternatives, grammar, name, o, operators, token, tokens, unwrap;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.3
|
||||
(function() {
|
||||
var buildLocationData, extend, flatten, ref, repeat, syntaxErrorToString;
|
||||
|
||||
|
@ -201,7 +201,7 @@
|
|||
};
|
||||
|
||||
syntaxErrorToString = function() {
|
||||
var codeLine, colorize, colorsEnabled, end, filename, first_column, first_line, last_column, last_line, marker, ref1, ref2, start;
|
||||
var codeLine, colorize, colorsEnabled, end, filename, first_column, first_line, last_column, last_line, marker, ref1, ref2, ref3, ref4, start;
|
||||
if (!(this.code && this.location)) {
|
||||
return Error.prototype.toString.call(this);
|
||||
}
|
||||
|
@ -218,9 +218,9 @@
|
|||
end = first_line === last_line ? last_column + 1 : codeLine.length;
|
||||
marker = codeLine.slice(0, start).replace(/[^\s]/g, ' ') + repeat('^', end - start);
|
||||
if (typeof process !== "undefined" && process !== null) {
|
||||
colorsEnabled = process.stdout.isTTY && !process.env.NODE_DISABLE_COLORS;
|
||||
colorsEnabled = ((ref2 = process.stdout) != null ? ref2.isTTY : void 0) && !((ref3 = process.env) != null ? ref3.NODE_DISABLE_COLORS : void 0);
|
||||
}
|
||||
if ((ref2 = this.colorful) != null ? ref2 : colorsEnabled) {
|
||||
if ((ref4 = this.colorful) != null ? ref4 : colorsEnabled) {
|
||||
colorize = function(str) {
|
||||
return "\x1B[1;31m" + str + "\x1B[0m";
|
||||
};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.3
|
||||
(function() {
|
||||
var key, ref, val;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.3
|
||||
(function() {
|
||||
var BOM, BOOL, CALLABLE, CODE, COFFEE_ALIASES, COFFEE_ALIAS_MAP, COFFEE_KEYWORDS, COMMENT, COMPARE, COMPOUND_ASSIGN, HERECOMMENT_ILLEGAL, HEREDOC_DOUBLE, HEREDOC_INDENT, HEREDOC_SINGLE, HEREGEX, HEREGEX_OMIT, IDENTIFIER, INDENTABLE_CLOSERS, INDEXABLE, INVALID_ESCAPE, INVERSES, JSTOKEN, JS_FORBIDDEN, JS_KEYWORDS, LEADING_BLANK_LINE, LINE_BREAK, LINE_CONTINUER, LOGIC, Lexer, MATH, MULTI_DENT, NOT_REGEX, NUMBER, OPERATOR, POSSIBLY_DIVISION, REGEX, REGEX_FLAGS, REGEX_ILLEGAL, RELATION, RESERVED, Rewriter, SHIFT, SIMPLE_STRING_OMIT, STRICT_PROSCRIBED, STRING_DOUBLE, STRING_OMIT, STRING_SINGLE, STRING_START, TRAILING_BLANK_LINE, TRAILING_SPACES, UNARY, UNARY_MATH, VALID_FLAGS, WHITESPACE, compact, count, invertLiterate, key, locationDataToString, ref, ref1, repeat, starts, throwSyntaxError,
|
||||
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
||||
|
@ -64,7 +64,7 @@
|
|||
};
|
||||
|
||||
Lexer.prototype.identifierToken = function() {
|
||||
var colon, colonOffset, forcedIdentifier, id, idLength, input, match, poppedToken, prev, ref2, ref3, ref4, ref5, tag, tagToken;
|
||||
var alias, colon, colonOffset, forcedIdentifier, id, idLength, input, match, poppedToken, prev, ref2, ref3, ref4, ref5, tag, tagToken;
|
||||
if (!(match = IDENTIFIER.exec(this.chunk))) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -118,6 +118,7 @@
|
|||
}
|
||||
if (!forcedIdentifier) {
|
||||
if (indexOf.call(COFFEE_ALIASES, id) >= 0) {
|
||||
alias = id;
|
||||
id = COFFEE_ALIAS_MAP[id];
|
||||
}
|
||||
tag = (function() {
|
||||
|
@ -142,6 +143,9 @@
|
|||
})();
|
||||
}
|
||||
tagToken = this.token(tag, id, 0, idLength);
|
||||
if (alias) {
|
||||
tagToken.origin = [tag, alias, tagToken[2]];
|
||||
}
|
||||
tagToken.variable = !forcedIdentifier;
|
||||
if (poppedToken) {
|
||||
ref5 = [poppedToken[2].first_line, poppedToken[2].first_column], tagToken[2].first_line = ref5[0], tagToken[2].first_column = ref5[1];
|
||||
|
@ -208,7 +212,7 @@
|
|||
heredoc = quote.length === 3;
|
||||
ref2 = this.matchWithInterpolations(regex, quote), tokens = ref2.tokens, end = ref2.index;
|
||||
$ = tokens.length - 1;
|
||||
delimiter = quote[0];
|
||||
delimiter = quote.charAt(0);
|
||||
if (heredoc) {
|
||||
indent = null;
|
||||
doc = ((function() {
|
||||
|
@ -500,6 +504,9 @@
|
|||
ref2 = this.tokens, prev = ref2[ref2.length - 1];
|
||||
if (value === '=' && prev) {
|
||||
if (!prev[1].reserved && (ref3 = prev[1], indexOf.call(JS_FORBIDDEN, ref3) >= 0)) {
|
||||
if (prev.origin) {
|
||||
prev = prev.origin;
|
||||
}
|
||||
this.error("reserved word '" + prev[1] + "' can't be assigned", prev[2]);
|
||||
}
|
||||
if ((ref4 = prev[1]) === '||' || ref4 === '&&') {
|
||||
|
@ -946,7 +953,7 @@
|
|||
|
||||
HEREDOC_INDENT = /\n+([^\n\S]*)(?=\S)/g;
|
||||
|
||||
REGEX = /^\/(?!\/)((?:[^[\/\n\\]|\\[^\n]|\[(?:\\[^\n]|[^\]\n\\])*])*)(\/)?/;
|
||||
REGEX = /^\/(?!\/)((?:[^[\/\n\\]|\\[^\n]|\[(?:\\[^\n]|[^\]\n\\])*\])*)(\/)?/;
|
||||
|
||||
REGEX_FLAGS = /^\w*/;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.3
|
||||
(function() {
|
||||
var Access, Arr, Assign, Base, Block, Call, Class, Code, CodeFragment, Comment, Existence, Expansion, Extends, For, HEXNUM, IDENTIFIER, IS_REGEX, IS_STRING, If, In, Index, LEVEL_ACCESS, LEVEL_COND, LEVEL_LIST, LEVEL_OP, LEVEL_PAREN, LEVEL_TOP, Literal, NEGATE, NO, NUMBER, Obj, Op, Param, Parens, RESERVED, Range, Return, SIMPLENUM, STRICT_PROSCRIBED, Scope, Slice, Splat, Switch, TAB, THIS, Throw, Try, UTILITIES, Value, While, YES, addLocationDataFn, compact, del, ends, extend, flatten, fragmentsToText, isComplexOrAssignable, isLiteralArguments, isLiteralThis, locationDataToString, merge, multident, parseNum, ref1, ref2, some, starts, throwSyntaxError, unfoldSoak, utility,
|
||||
extend1 = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
||||
|
@ -87,7 +87,7 @@
|
|||
};
|
||||
|
||||
Base.prototype.compileClosure = function(o) {
|
||||
var args, argumentsNode, func, jumpNode, meth, parts;
|
||||
var args, argumentsNode, func, jumpNode, meth, parts, ref3;
|
||||
if (jumpNode = this.jumps()) {
|
||||
jumpNode.error('cannot use a pure statement in an expression');
|
||||
}
|
||||
|
@ -105,7 +105,7 @@
|
|||
func = new Value(func, [new Access(new Literal(meth))]);
|
||||
}
|
||||
parts = (new Call(func, args)).compileNode(o);
|
||||
if (func.isGenerator) {
|
||||
if (func.isGenerator || ((ref3 = func.base) != null ? ref3.isGenerator : void 0)) {
|
||||
parts.unshift(this.makeCode("(yield* "));
|
||||
parts.push(this.makeCode(")"));
|
||||
}
|
||||
|
@ -868,7 +868,7 @@
|
|||
|
||||
Comment.prototype.compileNode = function(o, level) {
|
||||
var code, comment;
|
||||
comment = this.comment.replace(/^(\s*)# /gm, "$1 * ");
|
||||
comment = this.comment.replace(/^(\s*)#(?=\s)/gm, "$1 *");
|
||||
code = "/*" + (multident(comment, this.tab)) + (indexOf.call(comment, '\n') >= 0 ? "\n" + this.tab : '') + " */";
|
||||
if ((level || o.level) === LEVEL_TOP) {
|
||||
code = o.indent + code;
|
||||
|
@ -1311,7 +1311,7 @@
|
|||
indent += TAB;
|
||||
}
|
||||
if (prop instanceof Assign && prop.variable instanceof Value && prop.variable.hasProperties()) {
|
||||
prop.variable.error('Invalid object key');
|
||||
prop.variable.error('invalid object key');
|
||||
}
|
||||
if (prop instanceof Value && prop["this"]) {
|
||||
prop = new Assign(prop.properties[0].name, prop, 'object');
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.3
|
||||
(function() {
|
||||
var LONG_FLAG, MULTI_FLAG, OPTIONAL, OptionParser, SHORT_FLAG, buildRule, buildRules, normalizeArguments, repeat;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.3
|
||||
(function() {
|
||||
var CoffeeScript, Module, binary, child_process, ext, findExtension, fork, helpers, i, len, loadFile, path, ref;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.3
|
||||
(function() {
|
||||
var CoffeeScript, addHistory, addMultilineHandler, fs, getCommandId, merge, nodeREPL, path, ref, replDefaults, updateSyntaxError, vm;
|
||||
var CoffeeScript, addHistory, addMultilineHandler, fs, getCommandId, merge, nodeREPL, path, ref, replDefaults, runInContext, updateSyntaxError, vm;
|
||||
|
||||
fs = require('fs');
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
|||
historyFile: process.env.HOME ? path.join(process.env.HOME, '.coffee_history') : void 0,
|
||||
historyMaxInputSize: 10240,
|
||||
"eval": function(input, context, filename, cb) {
|
||||
var Assign, Block, Literal, Value, ast, err, js, ref1, referencedVars, result, token, tokens;
|
||||
var Assign, Block, Literal, Value, ast, err, js, ref1, referencedVars, token, tokens;
|
||||
input = input.replace(/\uFF00/g, '\n');
|
||||
input = input.replace(/^\(([\s\S]*)\n\)$/m, '$1');
|
||||
ref1 = require('./nodes'), Block = ref1.Block, Assign = ref1.Assign, Value = ref1.Value, Literal = ref1.Literal;
|
||||
|
@ -43,8 +43,7 @@
|
|||
locals: Object.keys(context),
|
||||
referencedVars: referencedVars
|
||||
});
|
||||
result = context === global ? vm.runInThisContext(js, filename) : vm.runInContext(js, context, filename);
|
||||
return cb(null, result);
|
||||
return cb(null, runInContext(js, context, filename));
|
||||
} catch (_error) {
|
||||
err = _error;
|
||||
updateSyntaxError(err, input);
|
||||
|
@ -53,6 +52,14 @@
|
|||
}
|
||||
};
|
||||
|
||||
runInContext = function(js, context, filename) {
|
||||
if (context === global) {
|
||||
return vm.runInThisContext(js, filename);
|
||||
} else {
|
||||
return vm.runInContext(js, context, filename);
|
||||
}
|
||||
};
|
||||
|
||||
addMultilineHandler = function(repl) {
|
||||
var inputStream, multiline, nodeLineListener, origPrompt, outputStream, ref1, rli;
|
||||
rli = repl.rli, inputStream = repl.inputStream, outputStream = repl.outputStream;
|
||||
|
@ -118,6 +125,7 @@
|
|||
readFd = fs.openSync(filename, 'r');
|
||||
buffer = new Buffer(size);
|
||||
fs.readSync(readFd, buffer, 0, size, stat.size - size);
|
||||
fs.close(readFd);
|
||||
repl.rli.history = buffer.toString().split('\n').reverse();
|
||||
if (stat.size > maxSize) {
|
||||
repl.rli.history.pop();
|
||||
|
@ -135,7 +143,7 @@
|
|||
return lastLine = code;
|
||||
}
|
||||
});
|
||||
repl.rli.on('exit', function() {
|
||||
repl.on('exit', function() {
|
||||
return fs.close(fd);
|
||||
});
|
||||
return repl.commands[getCommandId(repl, 'history')] = {
|
||||
|
@ -174,8 +182,13 @@
|
|||
process.argv = ['coffee'].concat(process.argv.slice(2));
|
||||
opts = merge(replDefaults, opts);
|
||||
repl = nodeREPL.start(opts);
|
||||
if (opts.prelude) {
|
||||
runInContext(opts.prelude, repl.context, 'prelude');
|
||||
}
|
||||
repl.on('exit', function() {
|
||||
return repl.outputStream.write('\n');
|
||||
if (!repl.rli.closed) {
|
||||
return repl.outputStream.write('\n');
|
||||
}
|
||||
});
|
||||
addMultilineHandler(repl);
|
||||
if (opts.historyFile) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.3
|
||||
(function() {
|
||||
var BALANCED_PAIRS, CALL_CLOSERS, EXPRESSION_CLOSE, EXPRESSION_END, EXPRESSION_START, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, IMPLICIT_UNSPACED_CALL, INVERSES, LINEBREAKS, SINGLE_CLOSERS, SINGLE_LINERS, generate, k, left, len, ref, rite,
|
||||
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
|
||||
|
@ -284,7 +284,7 @@
|
|||
startImplicitCall(i + 1);
|
||||
return forward(2);
|
||||
}
|
||||
if (indexOf.call(IMPLICIT_FUNC, tag) >= 0 && this.indexOfTag(i + 1, 'INDENT', null, ':') > -1 && !this.findTagsBackwards(i, ['CLASS', 'EXTENDS', 'IF', 'CATCH', 'SWITCH', 'LEADING_WHEN', 'FOR', 'WHILE', 'UNTIL'])) {
|
||||
if (indexOf.call(IMPLICIT_FUNC, tag) >= 0 && this.indexOfTag(i + 1, 'INDENT') > -1 && this.looksObjectish(i + 2) && !this.findTagsBackwards(i, ['CLASS', 'EXTENDS', 'IF', 'CATCH', 'SWITCH', 'LEADING_WHEN', 'FOR', 'WHILE', 'UNTIL'])) {
|
||||
startImplicitCall(i + 1);
|
||||
stack.push(['INDENT', i + 2]);
|
||||
return forward(3);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.3
|
||||
(function() {
|
||||
var Scope,
|
||||
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Generated by CoffeeScript 1.9.1
|
||||
// Generated by CoffeeScript 1.9.3
|
||||
(function() {
|
||||
var LineMap, SourceMap;
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
"author": {
|
||||
"name": "Jeremy Ashkenas"
|
||||
},
|
||||
"version": "1.9.1",
|
||||
"version": "1.9.3",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.8.0"
|
||||
|
@ -43,10 +43,10 @@
|
|||
"underscore": "~1.5.2",
|
||||
"docco": "~0.7.0"
|
||||
},
|
||||
"gitHead": "533ad8afe920b2dbf64ffb00efda45648242cc24",
|
||||
"_id": "coffee-script@1.9.1",
|
||||
"_shasum": "c458d02200f460d064a79cb6ab1ee6e2c9ca1c31",
|
||||
"_from": "coffee-script@1.9.1",
|
||||
"gitHead": "c37f284771e10b36239c714dcc40827510a6df5f",
|
||||
"_id": "coffee-script@1.9.3",
|
||||
"_shasum": "596e6e83fcfcb67c5964ab70d444beff0ac04ac7",
|
||||
"_from": "coffee-script@1.9.3",
|
||||
"_npmVersion": "1.4.28",
|
||||
"_npmUser": {
|
||||
"name": "jashkenas",
|
||||
|
@ -63,9 +63,8 @@
|
|||
}
|
||||
],
|
||||
"dist": {
|
||||
"shasum": "c458d02200f460d064a79cb6ab1ee6e2c9ca1c31",
|
||||
"tarball": "http://registry.npmjs.org/coffee-script/-/coffee-script-1.9.1.tgz"
|
||||
"shasum": "596e6e83fcfcb67c5964ab70d444beff0ac04ac7",
|
||||
"tarball": "http://registry.npmjs.org/coffee-script/-/coffee-script-1.9.3.tgz"
|
||||
},
|
||||
"_resolved": "https://registry.npmjs.org/coffee-script/-/coffee-script-1.9.1.tgz",
|
||||
"readme": "ERROR: No README data found!"
|
||||
"_resolved": "https://registry.npmjs.org/coffee-script/-/coffee-script-1.9.3.tgz"
|
||||
}
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
examples
|
||||
sandbox.js
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
# Travis optimizations, see http://docs.travis-ci.com/user/workers/container-based-infrastructure/
|
||||
sudo: false
|
||||
cache:
|
||||
directories:
|
||||
- node_modules
|
||||
install: npm update
|
||||
|
||||
#cache:
|
||||
# directories:
|
||||
# - node_modules
|
||||
#install: npm update
|
||||
|
||||
language: node_js
|
||||
|
||||
|
@ -15,8 +16,9 @@ node_js:
|
|||
deploy:
|
||||
provider: npm
|
||||
email: marsup@gmail.com
|
||||
edge: true
|
||||
api_key:
|
||||
secure: IuIigctAboFy2AGAcv/jUgRaVEQr23FX8ao+MM5fvmVpRZ/isHNQdJ2y1AAnCu5mCU+FgjNaXw/sB37J3Le5emMKhZMivXMTwAuLIbusEiQI6lzXflE7/+QK59jEcf/e5o6guTCf3CLMKo/yCrROYc/5sBuZuUqX2yDS6acGmZs=
|
||||
secure: kY6qx95hnKJkiuriRRizFf2k2hneCVbGjZEds81hyL0SscdaCpd2UbkeY3fL/XrFfJaagdmDdEQ+H+y8+kTzOID/9HVnpcwVSCrPG20+eHDYL6ZdZCFOsGqq0ggi38XBp7WS1AHvq3uDGTYzoJdQDgA6RNqIBBim+o3zUKRpu34=
|
||||
on:
|
||||
branch: master
|
||||
tags: true
|
||||
|
|
|
@ -36,11 +36,12 @@ Lead Maintainer: [Nicolas Morel](https://github.com/marsup)
|
|||
- [`any.unit(name)`](#anyunitname)
|
||||
- [`any.options(options)`](#anyoptionsoptions)
|
||||
- [`any.strict(isStrict)`](#anystrictisstrict)
|
||||
- [`any.default(value, [description])`](#anydefaultvalue-description)
|
||||
- [`any.default([value, [description]])`](#anydefaultvalue-description)
|
||||
- [`any.concat(schema)`](#anyconcatschema)
|
||||
- [`any.when(ref, options)`](#anywhenref-options)
|
||||
- [`any.label(name)`](#anylabelname)
|
||||
- [`any.raw(isRaw)`](#anyrawisraw)
|
||||
- [`any.empty(schema)`](#anyemptyschema)
|
||||
- [`array`](#array)
|
||||
- [`array.sparse(enabled)`](#arraysparseenabled)
|
||||
- [`array.single(enabled)`](#arraysingleenabled)
|
||||
|
@ -69,6 +70,8 @@ Lead Maintainer: [Nicolas Morel](https://github.com/marsup)
|
|||
- [`number.integer()`](#numberinteger)
|
||||
- [`number.precision(limit)`](#numberprecisionlimit)
|
||||
- [`number.multiple(base)`](#numbermultiplebase)
|
||||
- [`number.positive()`](#numberpositive)
|
||||
- [`number.negative()`](#numbernegative)
|
||||
- [`object`](#object)
|
||||
- [`object.keys([schema])`](#objectkeysschema)
|
||||
- [`object.min(limit)`](#objectminlimit)
|
||||
|
@ -196,7 +199,7 @@ Validates a value using the given schema and options where:
|
|||
- `convert` - when `true`, attempts to cast values to the required types (e.g. a string to a number). Defaults to `true`.
|
||||
- `allowUnknown` - when `true`, allows object to contain unknown keys which are ignored. Defaults to `false`.
|
||||
- `skipFunctions` - when `true`, ignores unknown keys with a function value. Defaults to `false`.
|
||||
- `stripUnknown` - when `true`, unknown keys are deleted (only when value is an object). Defaults to `false`.
|
||||
- `stripUnknown` - when `true`, unknown keys are deleted (only when value is an object or an array). Defaults to `false`.
|
||||
- `language` - overrides individual error messages, when `'label'` is set, it overrides the key name in the error message. Defaults to no override (`{}`).
|
||||
- `presence` - sets the default presence requirements. Supported modes: `'optional'`, `'required'`, and `'forbidden'`.
|
||||
Defaults to `'optional'`.
|
||||
|
@ -437,10 +440,13 @@ Strict mode sets the `options.convert` options to `false` which prevent type cas
|
|||
var schema = Joi.any().strict();
|
||||
```
|
||||
|
||||
#### `any.default(value, [description])`
|
||||
#### `any.default([value, [description]])`
|
||||
|
||||
Sets a default value if the original value is undefined where:
|
||||
- `value` - the value. `value` supports [references](#refkey-options). `value` may also be a function which returns the default value. If `value` is specified as a function that accepts a single parameter, that parameter will be a context object that can be used to derive the resulting value. **This clones the object however, which incurs some overhead so if you don't need access to the context define your method so that it does not accept any parameters**.
|
||||
- `value` - the value.
|
||||
- `value` supports [references](#refkey-options).
|
||||
- `value` may also be a function which returns the default value. If `value` is specified as a function that accepts a single parameter, that parameter will be a context object that can be used to derive the resulting value. **This clones the object however, which incurs some overhead so if you don't need access to the context define your method so that it does not accept any parameters**.
|
||||
- without any `value`, `default` has no effect, except for `object` that will then create nested defaults (applying inner defaults of that object).
|
||||
|
||||
Note that if `value` is an object, any changes to the object after `default()` is called will change the reference
|
||||
and any future assignment.
|
||||
|
@ -476,7 +482,7 @@ Joi.validate({
|
|||
#### `any.concat(schema)`
|
||||
|
||||
Returns a new type that is the result of adding the rules of one type to another where:
|
||||
- `schema` - a **joi** type to merge into the current schema. Can only be of the same type as the context type or `any`.
|
||||
- `schema` - a **joi** type to merge into the current schema. Can only be of the same type as the context type or `any`. If applied to an `any` type, the schema can be any other schema.
|
||||
|
||||
```javascript
|
||||
var a = Joi.string().valid('a');
|
||||
|
@ -532,6 +538,18 @@ var schema = {
|
|||
};
|
||||
```
|
||||
|
||||
#### `any.empty(schema)`
|
||||
|
||||
Considers anything that matches the schema to be empty (`undefined`).
|
||||
- `schema` - any object or joi schema to match. An undefined schema unsets that rule.
|
||||
|
||||
```js
|
||||
var schema = Joi.string().empty('');
|
||||
schema.validate(''); // returns { error: null, value: undefined }
|
||||
schema = schema.empty();
|
||||
schema.validate(''); // returns { error: "value" is not allowed to be empty, value: '' }
|
||||
```
|
||||
|
||||
### `array`
|
||||
|
||||
Generates a schema object that matches an array data type. Note that undefined values inside arrays are not allowed by default but can be by using `sparse()`.
|
||||
|
@ -868,6 +886,22 @@ Specifies that the value must be a multiple of `base`:
|
|||
var schema = Joi.number().multiple(3);
|
||||
```
|
||||
|
||||
#### `number.positive()`
|
||||
|
||||
Requires the number to be positive.
|
||||
|
||||
```javascript
|
||||
var schema = Joi.number().positive();
|
||||
```
|
||||
|
||||
#### `number.negative()`
|
||||
|
||||
Requires the number to be negative.
|
||||
|
||||
```javascript
|
||||
var schema = Joi.number().negative();
|
||||
```
|
||||
|
||||
### `object`
|
||||
|
||||
Generates a schema object that matches an object data type (as well as JSON strings that parsed into objects). Defaults
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
module.exports = require('./lib');
|
|
@ -79,10 +79,16 @@ internals.Alternatives.prototype.when = function (ref, options) {
|
|||
Hoek.assert(options.then !== undefined || options.otherwise !== undefined, 'options must have at least one of "then" or "otherwise"');
|
||||
|
||||
var obj = this.clone();
|
||||
var is = Cast.schema(options.is);
|
||||
|
||||
if (options.is === null || !options.is.isJoi) {
|
||||
// Only apply required if this wasn't already a schema, we'll suppose people know what they're doing
|
||||
is = is.required();
|
||||
}
|
||||
|
||||
var item = {
|
||||
ref: Cast.ref(ref),
|
||||
is: Cast.schema(options.is),
|
||||
is: is,
|
||||
then: options.then !== undefined ? Cast.schema(options.then) : undefined,
|
||||
otherwise: options.otherwise !== undefined ? Cast.schema(options.otherwise) : undefined
|
||||
};
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
// Load modules
|
||||
|
||||
var Path = require('path');
|
||||
var Hoek = require('hoek');
|
||||
var Ref = require('./ref');
|
||||
var Errors = require('./errors');
|
||||
|
@ -28,6 +27,7 @@ internals.defaults = {
|
|||
|
||||
|
||||
internals.checkOptions = function (options) {
|
||||
|
||||
var optionType = {
|
||||
abortEarly: 'boolean',
|
||||
convert: 'boolean',
|
||||
|
@ -64,6 +64,8 @@ internals.checkOptions = function (options) {
|
|||
|
||||
module.exports = internals.Any = function () {
|
||||
|
||||
Cast = Cast || require('./cast');
|
||||
|
||||
this.isJoi = true;
|
||||
this._type = 'any';
|
||||
this._settings = null;
|
||||
|
@ -80,7 +82,8 @@ module.exports = internals.Any = function () {
|
|||
encoding: undefined,
|
||||
insensitive: false,
|
||||
trim: false,
|
||||
case: undefined // upper, lower
|
||||
case: undefined, // upper, lower
|
||||
empty: undefined
|
||||
*/ };
|
||||
|
||||
this._description = null;
|
||||
|
@ -131,10 +134,23 @@ internals.Any.prototype.clone = function () {
|
|||
internals.Any.prototype.concat = function (schema) {
|
||||
|
||||
Hoek.assert(schema && schema.isJoi, 'Invalid schema object');
|
||||
Hoek.assert(schema._type === 'any' || schema._type === this._type, 'Cannot merge with another type:', schema._type);
|
||||
Hoek.assert(this._type === 'any' || schema._type === 'any' || schema._type === this._type, 'Cannot merge type', this._type, 'with another type:', schema._type);
|
||||
|
||||
var obj = this.clone();
|
||||
|
||||
if (this._type === 'any' && schema._type !== 'any') {
|
||||
// Reset values as if we were "this"
|
||||
var tmpObj = schema.clone();
|
||||
var keysToRestore = ['_settings', '_valids', '_invalids', '_tests', '_refs', '_flags', '_description', '_unit',
|
||||
'_notes', '_tags', '_examples', '_meta', '_inner'];
|
||||
|
||||
for (var j = 0, jl = keysToRestore.length; j < jl; ++j) {
|
||||
tmpObj[keysToRestore[j]] = obj[keysToRestore[j]];
|
||||
}
|
||||
|
||||
obj = tmpObj;
|
||||
}
|
||||
|
||||
obj._settings = obj._settings ? internals.concatSettings(obj._settings, schema._settings) : schema._settings;
|
||||
obj._valids.merge(schema._valids, schema._invalids);
|
||||
obj._invalids.merge(schema._invalids, schema._valids);
|
||||
|
@ -347,12 +363,29 @@ internals.Any.prototype.default = function (value, description) {
|
|||
};
|
||||
|
||||
|
||||
internals.Any.prototype.empty = function (schema) {
|
||||
|
||||
var obj;
|
||||
if (schema === undefined) {
|
||||
obj = this.clone();
|
||||
obj._flags.empty = undefined;
|
||||
}
|
||||
else {
|
||||
schema = Cast.schema(schema);
|
||||
|
||||
obj = this.clone();
|
||||
obj._flags.empty = schema;
|
||||
}
|
||||
|
||||
return obj;
|
||||
};
|
||||
|
||||
|
||||
internals.Any.prototype.when = function (ref, options) {
|
||||
|
||||
Hoek.assert(options && typeof options === 'object', 'Invalid options');
|
||||
Hoek.assert(options.then !== undefined || options.otherwise !== undefined, 'options must have at least one of "then" or "otherwise"');
|
||||
|
||||
Cast = Cast || require('./cast');
|
||||
var then = options.then ? this.concat(Cast.schema(options.then)) : this;
|
||||
var otherwise = options.otherwise ? this.concat(Cast.schema(options.otherwise)) : this;
|
||||
|
||||
|
@ -500,7 +533,13 @@ internals.Any.prototype._validate = function (value, state, options, reference)
|
|||
var presence = this._flags.presence || options.presence;
|
||||
if (presence === 'optional') {
|
||||
if (value === undefined) {
|
||||
return finish();
|
||||
var isDeepDefault = this._flags.hasOwnProperty('default') && this._flags.default === undefined;
|
||||
if (isDeepDefault && this._type === 'object') {
|
||||
value = {};
|
||||
}
|
||||
else {
|
||||
return finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (presence === 'required' &&
|
||||
|
@ -518,6 +557,11 @@ internals.Any.prototype._validate = function (value, state, options, reference)
|
|||
return finish();
|
||||
}
|
||||
|
||||
if (this._flags.empty && !this._flags.empty._validate(value, null, internals.defaults).errors) {
|
||||
value = undefined;
|
||||
return finish();
|
||||
}
|
||||
|
||||
// Check allowed and denied values using the original value
|
||||
|
||||
if (this._valids.has(value, state, options, this._flags.insensitive)) {
|
||||
|
@ -624,8 +668,18 @@ internals.Any.prototype.describe = function () {
|
|||
type: this._type
|
||||
};
|
||||
|
||||
if (Object.keys(this._flags).length) {
|
||||
description.flags = this._flags;
|
||||
var flags = Object.keys(this._flags);
|
||||
if (flags.length) {
|
||||
if (this._flags.empty) {
|
||||
description.flags = {};
|
||||
for (var f = 0, fl = flags.length; f < fl; ++f) {
|
||||
var flag = flags[f];
|
||||
description.flags[flag] = flag === 'empty' ? this._flags[flag].describe() : this._flags[flag];
|
||||
}
|
||||
}
|
||||
else {
|
||||
description.flags = this._flags;
|
||||
}
|
||||
}
|
||||
|
||||
if (this._description) {
|
||||
|
|
|
@ -191,16 +191,16 @@ internals.checkItems = function (items, wasArray, state, options) {
|
|||
}
|
||||
}
|
||||
|
||||
if (options.stripUnknown) {
|
||||
internals.fastSplice(items, v);
|
||||
--v;
|
||||
--vl;
|
||||
isValid = true;
|
||||
break;
|
||||
}
|
||||
|
||||
// Return the actual error if only one inclusion defined
|
||||
if (il === 1) {
|
||||
if (options.stripUnknown) {
|
||||
internals.fastSplice(items, v);
|
||||
--v;
|
||||
--vl;
|
||||
isValid = true;
|
||||
break;
|
||||
}
|
||||
|
||||
errors.push(Errors.create(wasArray ? 'array.includesOne' : 'array.includesOneSingle', { pos: v, reason: res.errors, value: item }, { key: state.key, path: localState.path }, options));
|
||||
errored = true;
|
||||
|
||||
|
@ -217,6 +217,13 @@ internals.checkItems = function (items, wasArray, state, options) {
|
|||
}
|
||||
|
||||
if (this._inner.inclusions.length && !isValid) {
|
||||
if (options.stripUnknown) {
|
||||
internals.fastSplice(items, v);
|
||||
--v;
|
||||
--vl;
|
||||
continue;
|
||||
}
|
||||
|
||||
errors.push(Errors.create(wasArray ? 'array.includes' : 'array.includesSingle', { pos: v, value: item }, { key: state.key, path: localState.path }, options));
|
||||
|
||||
if (options.abortEarly) {
|
||||
|
@ -226,35 +233,41 @@ internals.checkItems = function (items, wasArray, state, options) {
|
|||
}
|
||||
|
||||
if (requireds.length) {
|
||||
var knownMisses = [];
|
||||
var unknownMisses = 0;
|
||||
for (var i = 0, il = requireds.length; i < il; ++i) {
|
||||
var label = Hoek.reach(requireds[i], '_settings.language.label');
|
||||
if (label) {
|
||||
knownMisses.push(label);
|
||||
}
|
||||
else {
|
||||
++unknownMisses;
|
||||
}
|
||||
}
|
||||
|
||||
if (knownMisses.length) {
|
||||
if (unknownMisses) {
|
||||
errors.push(Errors.create('array.includesRequiredBoth', { knownMisses: knownMisses, unknownMisses: unknownMisses }, { key: state.key, path: state.patk }, options));
|
||||
}
|
||||
else {
|
||||
errors.push(Errors.create('array.includesRequiredKnowns', { knownMisses: knownMisses }, { key: state.key, path: state.path }, options));
|
||||
}
|
||||
}
|
||||
else {
|
||||
errors.push(Errors.create('array.includesRequiredUnknowns', { unknownMisses: unknownMisses }, { key: state.key, path: state.path }, options));
|
||||
}
|
||||
internals.fillMissedErrors(errors, requireds, state, options);
|
||||
}
|
||||
|
||||
return errors.length ? errors : null;
|
||||
};
|
||||
|
||||
|
||||
internals.fillMissedErrors = function (errors, requireds, state, options) {
|
||||
|
||||
var knownMisses = [];
|
||||
var unknownMisses = 0;
|
||||
for (var i = 0, il = requireds.length; i < il; ++i) {
|
||||
var label = Hoek.reach(requireds[i], '_settings.language.label');
|
||||
if (label) {
|
||||
knownMisses.push(label);
|
||||
}
|
||||
else {
|
||||
++unknownMisses;
|
||||
}
|
||||
}
|
||||
|
||||
if (knownMisses.length) {
|
||||
if (unknownMisses) {
|
||||
errors.push(Errors.create('array.includesRequiredBoth', { knownMisses: knownMisses, unknownMisses: unknownMisses }, { key: state.key, path: state.patk }, options));
|
||||
}
|
||||
else {
|
||||
errors.push(Errors.create('array.includesRequiredKnowns', { knownMisses: knownMisses }, { key: state.key, path: state.path }, options));
|
||||
}
|
||||
}
|
||||
else {
|
||||
errors.push(Errors.create('array.includesRequiredUnknowns', { unknownMisses: unknownMisses }, { key: state.key, path: state.path }, options));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
internals.Array.prototype.describe = function () {
|
||||
|
||||
var description = Any.prototype.describe.call(this);
|
||||
|
|
|
@ -13,7 +13,7 @@ var internals = {};
|
|||
|
||||
internals.isoDate = /^((\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\d))$/;
|
||||
internals.invalidDate = new Date('');
|
||||
internals.isIsoDate = (function() {
|
||||
internals.isIsoDate = (function () {
|
||||
|
||||
var isoString = internals.isoDate.toString();
|
||||
|
||||
|
@ -107,7 +107,7 @@ internals.compare = function (type, compare) {
|
|||
compareTo = Date.now();
|
||||
}
|
||||
else if (isRef) {
|
||||
compareTo = internals.toDate(date(state.parent));
|
||||
compareTo = internals.toDate(date(state.parent, options));
|
||||
|
||||
if (!compareTo) {
|
||||
return Errors.create('date.ref', { ref: date.key }, state, options);
|
||||
|
|
|
@ -165,46 +165,46 @@ internals.getPath = function (item) {
|
|||
// Inspired by json-stringify-safe
|
||||
internals.safeStringify = function (obj, spaces) {
|
||||
|
||||
return JSON.stringify(obj, internals.serializer(), spaces);
|
||||
return JSON.stringify(obj, internals.serializer(), spaces);
|
||||
};
|
||||
|
||||
internals.serializer = function () {
|
||||
|
||||
var cycleReplacer = function (key, value) {
|
||||
var cycleReplacer = function (key, value) {
|
||||
|
||||
if (stack[0] === value) {
|
||||
return '[Circular ~]';
|
||||
}
|
||||
if (stack[0] === value) {
|
||||
return '[Circular ~]';
|
||||
}
|
||||
|
||||
return '[Circular ~.' + keys.slice(0, stack.indexOf(value)).join('.') + ']';
|
||||
};
|
||||
return '[Circular ~.' + keys.slice(0, stack.indexOf(value)).join('.') + ']';
|
||||
};
|
||||
|
||||
var keys = [], stack = [];
|
||||
var keys = [], stack = [];
|
||||
|
||||
return function (key, value) {
|
||||
return function (key, value) {
|
||||
|
||||
if (stack.length > 0) {
|
||||
var thisPos = stack.indexOf(this);
|
||||
if (~thisPos) {
|
||||
stack.length = thisPos + 1;
|
||||
keys.length = thisPos + 1;
|
||||
keys[thisPos] = key;
|
||||
}
|
||||
else {
|
||||
stack.push(this);
|
||||
keys.push(key);
|
||||
}
|
||||
if (stack.length > 0) {
|
||||
var thisPos = stack.indexOf(this);
|
||||
if (~thisPos) {
|
||||
stack.length = thisPos + 1;
|
||||
keys.length = thisPos + 1;
|
||||
keys[thisPos] = key;
|
||||
}
|
||||
else {
|
||||
stack.push(this);
|
||||
keys.push(key);
|
||||
}
|
||||
|
||||
if (~stack.indexOf(value)) {
|
||||
value = cycleReplacer.call(this, key, value);
|
||||
}
|
||||
}
|
||||
else {
|
||||
stack.push(value);
|
||||
}
|
||||
if (~stack.indexOf(value)) {
|
||||
value = cycleReplacer.call(this, key, value);
|
||||
}
|
||||
}
|
||||
else {
|
||||
stack.push(value);
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
||||
return value;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ internals.compare = function (type, compare) {
|
|||
|
||||
var compareTo;
|
||||
if (isRef) {
|
||||
compareTo = limit(state.parent);
|
||||
compareTo = limit(state.parent, options);
|
||||
|
||||
if (!(typeof compareTo === 'number' && !isNaN(compareTo))) {
|
||||
return Errors.create('number.ref', { ref: limit.key }, state, options);
|
||||
|
|
|
@ -27,6 +27,7 @@ Hoek.inherits(internals.Object, Any);
|
|||
|
||||
internals.Object.prototype._base = function (value, state, options) {
|
||||
|
||||
var item, key, localState, result;
|
||||
var target = value;
|
||||
var errors = [];
|
||||
var finish = function () {
|
||||
|
@ -43,7 +44,7 @@ internals.Object.prototype._base = function (value, state, options) {
|
|||
try {
|
||||
value = JSON.parse(value);
|
||||
}
|
||||
catch (err) { }
|
||||
catch (parseErr) { }
|
||||
}
|
||||
|
||||
if (!value ||
|
||||
|
@ -82,7 +83,7 @@ internals.Object.prototype._base = function (value, state, options) {
|
|||
|
||||
var renamed = {};
|
||||
for (var r = 0, rl = this._inner.renames.length; r < rl; ++r) {
|
||||
var item = this._inner.renames[r];
|
||||
item = this._inner.renames[r];
|
||||
|
||||
if (item.options.ignoreUndefined && target[item.from] === undefined) {
|
||||
continue;
|
||||
|
@ -121,40 +122,27 @@ internals.Object.prototype._base = function (value, state, options) {
|
|||
}
|
||||
}
|
||||
|
||||
// Validate dependencies
|
||||
|
||||
for (var d = 0, dl = this._inner.dependencies.length; d < dl; ++d) {
|
||||
var dep = this._inner.dependencies[d];
|
||||
var err = internals[dep.type](dep.key !== null && value[dep.key], dep.peers, target, { key: dep.key, path: (state.path ? state.path + '.' : '') + (dep.key || '') }, options);
|
||||
if (err) {
|
||||
errors.push(err);
|
||||
if (options.abortEarly) {
|
||||
return finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Validate schema
|
||||
|
||||
if (!this._inner.children && // null allows any keys
|
||||
!this._inner.patterns.length) {
|
||||
!this._inner.patterns.length &&
|
||||
!this._inner.dependencies.length) {
|
||||
|
||||
return finish();
|
||||
}
|
||||
|
||||
var unprocessed = Hoek.mapToObject(Object.keys(target));
|
||||
var key;
|
||||
|
||||
if (this._inner.children) {
|
||||
for (var i = 0, il = this._inner.children.length; i < il; ++i) {
|
||||
var child = this._inner.children[i];
|
||||
var key = child.key;
|
||||
var item = target[key];
|
||||
key = child.key;
|
||||
item = target[key];
|
||||
|
||||
delete unprocessed[key];
|
||||
|
||||
var localState = { key: key, path: (state.path ? state.path + '.' : '') + key, parent: target, reference: state.reference };
|
||||
var result = child.schema._validate(item, localState, options);
|
||||
localState = { key: key, path: (state.path ? state.path + '.' : '') + key, parent: target, reference: state.reference };
|
||||
result = child.schema._validate(item, localState, options);
|
||||
if (result.errors) {
|
||||
errors.push(Errors.create('object.child', { key: key, reason: result.errors }, localState, options));
|
||||
|
||||
|
@ -179,7 +167,7 @@ internals.Object.prototype._base = function (value, state, options) {
|
|||
this._inner.patterns.length) {
|
||||
|
||||
for (i = 0, il = unprocessedKeys.length; i < il; ++i) {
|
||||
var key = unprocessedKeys[i];
|
||||
key = unprocessedKeys[i];
|
||||
|
||||
for (var p = 0, pl = this._inner.patterns.length; p < pl; ++p) {
|
||||
var pattern = this._inner.patterns[p];
|
||||
|
@ -187,9 +175,9 @@ internals.Object.prototype._base = function (value, state, options) {
|
|||
if (pattern.regex.test(key)) {
|
||||
delete unprocessed[key];
|
||||
|
||||
var item = target[key];
|
||||
var localState = { key: key, path: (state.path ? state.path + '.' : '') + key, parent: target, reference: state.reference };
|
||||
var result = pattern.rule._validate(item, localState, options);
|
||||
item = target[key];
|
||||
localState = { key: key, path: (state.path ? state.path + '.' : '') + key, parent: target, reference: state.reference };
|
||||
result = pattern.rule._validate(item, localState, options);
|
||||
if (result.errors) {
|
||||
errors.push(Errors.create('object.child', { key: key, reason: result.errors }, localState, options));
|
||||
|
||||
|
@ -208,7 +196,7 @@ internals.Object.prototype._base = function (value, state, options) {
|
|||
unprocessedKeys = Object.keys(unprocessed);
|
||||
}
|
||||
|
||||
if (unprocessedKeys.length) {
|
||||
if ((this._inner.children || this._inner.patterns.length) && unprocessedKeys.length) {
|
||||
if (options.stripUnknown ||
|
||||
options.skipFunctions) {
|
||||
|
||||
|
@ -243,6 +231,19 @@ internals.Object.prototype._base = function (value, state, options) {
|
|||
}
|
||||
}
|
||||
|
||||
// Validate dependencies
|
||||
|
||||
for (var d = 0, dl = this._inner.dependencies.length; d < dl; ++d) {
|
||||
var dep = this._inner.dependencies[d];
|
||||
var err = internals[dep.type](dep.key !== null && value[dep.key], dep.peers, target, { key: dep.key, path: (state.path ? state.path + '.' : '') + (dep.key || '') }, options);
|
||||
if (err) {
|
||||
errors.push(err);
|
||||
if (options.abortEarly) {
|
||||
return finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return finish();
|
||||
};
|
||||
|
||||
|
@ -267,16 +268,17 @@ internals.Object.prototype.keys = function (schema) {
|
|||
}
|
||||
|
||||
var topo = new Topo();
|
||||
var child;
|
||||
if (obj._inner.children) {
|
||||
for (var i = 0, il = obj._inner.children.length; i < il; ++i) {
|
||||
var child = obj._inner.children[i];
|
||||
child = obj._inner.children[i];
|
||||
topo.add(child, { after: child._refs, group: child.key });
|
||||
}
|
||||
}
|
||||
|
||||
for (var c = 0, cl = children.length; c < cl; ++c) {
|
||||
var key = children[c];
|
||||
var child = schema[key];
|
||||
child = schema[key];
|
||||
var cast = Cast.schema(child);
|
||||
topo.add({ key: key, schema: cast }, { after: cast._refs, group: key });
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ internals.compare = function (type, compare) {
|
|||
|
||||
var compareTo;
|
||||
if (isRef) {
|
||||
compareTo = limit(state.parent);
|
||||
compareTo = limit(state.parent, options);
|
||||
|
||||
if (!Hoek.isInteger(compareTo)) {
|
||||
return Errors.create('string.ref', { ref: limit.key }, state, options);
|
||||
|
@ -349,7 +349,7 @@ internals.String.prototype.hex = function () {
|
|||
|
||||
var regex = /^[a-f0-9]+$/i;
|
||||
|
||||
return this._test('guid', regex, function (value, state, options) {
|
||||
return this._test('hex', regex, function (value, state, options) {
|
||||
|
||||
if (regex.test(value)) {
|
||||
return null;
|
||||
|
|
|
@ -15,7 +15,7 @@ var internals = {
|
|||
}
|
||||
};
|
||||
|
||||
internals.Ip.createIpRegex = function(versions, cidr) {
|
||||
internals.Ip.createIpRegex = function (versions, cidr) {
|
||||
|
||||
var regex;
|
||||
for (var i = 0, il = versions.length; i < il; ++i) {
|
||||
|
|
|
@ -13,7 +13,7 @@ Lead Maintainer: [Nathan LaFreniere](https://github.com/nlf)
|
|||
* [clone](#cloneobj "clone")
|
||||
* [cloneWithShallow](#clonewithshallowobj-keys "cloneWithShallow")
|
||||
* [merge](#mergetarget-source-isnulloverride-ismergearrays "merge")
|
||||
* [applyToDefaults](#applytodefaultsdefaults-options "applyToDefaults")
|
||||
* [applyToDefaults](#applytodefaultsdefaults-options-isnulloverride "applyToDefaults")
|
||||
* [applyToDefaultsWithShallow](#applytodefaultswithshallowdefaults-options-keys "applyToDefaultsWithShallow")
|
||||
* [deepEqual](#deepequala-b "deepEqual")
|
||||
* [unique](#uniquearray-key "unique")
|
||||
|
@ -22,6 +22,7 @@ Lead Maintainer: [Nathan LaFreniere](https://github.com/nlf)
|
|||
* [contain](#containref-values-options "contain")
|
||||
* [flatten](#flattenarray-target "flatten")
|
||||
* [reach](#reachobj-chain-options "reach")
|
||||
* [reachTemplate](#reachobj-template-options "reachTemplate")
|
||||
* [transform](#transformobj-transform-options "transform")
|
||||
* [shallow](#shallowobj "shallow")
|
||||
* [stringify](#stringifyobj "stringify")
|
||||
|
@ -147,7 +148,8 @@ Hoek.merge(targetArray, sourceArray); // results in [1, 2, 3, 4, 5]
|
|||
Hoek.merge(targetArray, sourceArray, true, false); // results in [4, 5]
|
||||
```
|
||||
|
||||
### applyToDefaults(defaults, options)
|
||||
### applyToDefaults(defaults, options, isNullOverride)
|
||||
isNullOverride defaults to false
|
||||
|
||||
Apply options to a copy of the defaults
|
||||
|
||||
|
@ -159,6 +161,16 @@ var options = { port: 8080 };
|
|||
var config = Hoek.applyToDefaults(defaults, options); // results in { host: "localhost", port: 8080 }
|
||||
```
|
||||
|
||||
Apply options with a null value to a copy of the defaults
|
||||
|
||||
```javascript
|
||||
|
||||
var defaults = { host: "localhost", port: 8000 };
|
||||
var options = { host: null, port: 8080 };
|
||||
|
||||
var config = Hoek.applyToDefaults(defaults, options, true); // results in { host: null, port: 8080 }
|
||||
```
|
||||
|
||||
### applyToDefaultsWithShallow(defaults, options, keys)
|
||||
keys is an array of key names to shallow copy
|
||||
|
||||
|
@ -293,6 +305,23 @@ var obj = {a : {b : [2,3,6]}};
|
|||
Hoek.reach(obj, chain); // returns 6
|
||||
```
|
||||
|
||||
### reachTemplate(obj, template, [options])
|
||||
|
||||
Replaces string parameters (`{name}`) with their corresponding object key values by applying the
|
||||
(`reach()`)[#reachobj-chain-options] method where:
|
||||
|
||||
- `obj` - the context object used for key lookup.
|
||||
- `template` - a string containing `{}` parameters.
|
||||
- `options` - optional (`reach()`)[#reachobj-chain-options] options.
|
||||
|
||||
```javascript
|
||||
|
||||
var chain = 'a.b.c';
|
||||
var obj = {a : {b : { c : 1}}};
|
||||
|
||||
Hoek.reachTemplate(obj, '1+{a.b.c}=2'); // returns '1+1=2'
|
||||
```
|
||||
|
||||
### transform(obj, transform, [options])
|
||||
|
||||
Transforms an existing object into a new one based on the supplied `obj` and `transform` map. `options` are the same as the `reach` options.
|
||||
|
|
|
@ -43,7 +43,9 @@ exports.clone = function (obj, seen) {
|
|||
}
|
||||
else {
|
||||
var proto = Object.getPrototypeOf(obj);
|
||||
if (!proto || proto.isImmutable) {
|
||||
if (proto &&
|
||||
proto.isImmutable) {
|
||||
|
||||
newObj = obj;
|
||||
}
|
||||
else {
|
||||
|
@ -142,7 +144,7 @@ exports.merge = function (target, source, isNullOverride /* = true */, isMergeAr
|
|||
|
||||
// Apply options to a copy of the defaults
|
||||
|
||||
exports.applyToDefaults = function (defaults, options) {
|
||||
exports.applyToDefaults = function (defaults, options, isNullOverride) {
|
||||
|
||||
exports.assert(defaults && typeof defaults === 'object', 'Invalid defaults value: must be an object');
|
||||
exports.assert(!options || options === true || typeof options === 'object', 'Invalid options value: must be true, falsy or an object');
|
||||
|
@ -157,7 +159,7 @@ exports.applyToDefaults = function (defaults, options) {
|
|||
return copy;
|
||||
}
|
||||
|
||||
return exports.merge(copy, options, false, false);
|
||||
return exports.merge(copy, options, isNullOverride === true, false);
|
||||
};
|
||||
|
||||
|
||||
|
@ -280,12 +282,24 @@ exports.deepEqual = function (obj, ref, options, seen) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (obj.length !== ref.length) {
|
||||
if (!options.part && obj.length !== ref.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (var i = 0, il = obj.length; i < il; ++i) {
|
||||
if (!exports.deepEqual(obj[i], ref[i])) {
|
||||
if (options.part) {
|
||||
var found = false;
|
||||
for (var r = 0, rl = ref.length; r < rl; ++r) {
|
||||
if (exports.deepEqual(obj[i], ref[r], options, seen)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
if (!exports.deepEqual(obj[i], ref[i], options, seen)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -327,7 +341,7 @@ exports.deepEqual = function (obj, ref, options, seen) {
|
|||
|
||||
var keys = Object.getOwnPropertyNames(obj);
|
||||
|
||||
if (keys.length !== Object.getOwnPropertyNames(ref).length) {
|
||||
if (!options.part && keys.length !== Object.getOwnPropertyNames(ref).length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -448,7 +462,23 @@ exports.contain = function (ref, values, options) {
|
|||
exports.assert(typeof ref === 'string' || typeof ref === 'object', 'Reference must be string or an object');
|
||||
exports.assert(values.length, 'Values array cannot be empty');
|
||||
|
||||
var compare = options.deep ? exports.deepEqual : function (a, b) { return a === b; };
|
||||
var compare, compareFlags;
|
||||
if (options.deep) {
|
||||
compare = exports.deepEqual;
|
||||
|
||||
var hasOnly = options.hasOwnProperty('only'), hasPart = options.hasOwnProperty('part');
|
||||
|
||||
compareFlags = {
|
||||
prototype: hasOnly ? options.only : hasPart ? !options.part : false,
|
||||
part: hasOnly ? !options.only : hasPart ? options.part : true
|
||||
};
|
||||
}
|
||||
else {
|
||||
compare = function (a, b) {
|
||||
|
||||
return a === b;
|
||||
};
|
||||
}
|
||||
|
||||
var misses = false;
|
||||
var matches = new Array(values.length);
|
||||
|
@ -477,7 +507,7 @@ exports.contain = function (ref, values, options) {
|
|||
else if (Array.isArray(ref)) {
|
||||
for (i = 0, il = ref.length; i < il; ++i) {
|
||||
for (var j = 0, jl = values.length, matched = false; j < jl && matched === false; ++j) {
|
||||
matched = compare(ref[i], values[j]) && j;
|
||||
matched = compare(values[j], ref[i], compareFlags) && j;
|
||||
}
|
||||
|
||||
if (matched !== false) {
|
||||
|
@ -495,7 +525,7 @@ exports.contain = function (ref, values, options) {
|
|||
var pos = values.indexOf(key);
|
||||
if (pos !== -1) {
|
||||
if (valuePairs &&
|
||||
!compare(ref[key], valuePairs[key])) {
|
||||
!compare(valuePairs[key], ref[key], compareFlags)) {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -582,6 +612,16 @@ exports.reach = function (obj, chain, options) {
|
|||
};
|
||||
|
||||
|
||||
exports.reachTemplate = function (obj, template, options) {
|
||||
|
||||
return template.replace(/{([^}]+)}/g, function ($0, chain) {
|
||||
|
||||
var value = exports.reach(obj, chain, options);
|
||||
return (value === undefined || value === null ? '' : value);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
exports.formatStack = function (stack) {
|
||||
|
||||
var trace = [];
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
{
|
||||
"name": "hoek",
|
||||
"description": "General purpose node utilities",
|
||||
"version": "2.12.0",
|
||||
"version": "2.14.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/hapijs/hoek"
|
||||
"url": "git://github.com/hapijs/hoek.git"
|
||||
},
|
||||
"main": "index",
|
||||
"keywords": [
|
||||
|
@ -21,26 +21,25 @@
|
|||
"scripts": {
|
||||
"test": "make test-cov"
|
||||
},
|
||||
"licenses": [
|
||||
{
|
||||
"type": "BSD",
|
||||
"url": "http://github.com/hapijs/hoek/raw/master/LICENSE"
|
||||
}
|
||||
],
|
||||
"gitHead": "9bbb8f149b5b824f66b47ae4cf3afb1e2877396f",
|
||||
"license": "BSD-3-Clause",
|
||||
"gitHead": "e80875a516f4b0eaa757ac4814c4510eebdcf589",
|
||||
"bugs": {
|
||||
"url": "https://github.com/hapijs/hoek/issues"
|
||||
},
|
||||
"homepage": "https://github.com/hapijs/hoek",
|
||||
"_id": "hoek@2.12.0",
|
||||
"_shasum": "5d1196e0bf20c5cec957e8927101164effdaf1c9",
|
||||
"homepage": "https://github.com/hapijs/hoek#readme",
|
||||
"_id": "hoek@2.14.0",
|
||||
"_shasum": "81211691f52a5a835ae49edbf1e89c9003476aa4",
|
||||
"_from": "hoek@>=2.2.0 <3.0.0",
|
||||
"_npmVersion": "2.6.1",
|
||||
"_nodeVersion": "0.10.36",
|
||||
"_npmVersion": "2.9.0",
|
||||
"_nodeVersion": "0.12.2",
|
||||
"_npmUser": {
|
||||
"name": "nlf",
|
||||
"email": "quitlahok@gmail.com"
|
||||
},
|
||||
"dist": {
|
||||
"shasum": "81211691f52a5a835ae49edbf1e89c9003476aa4",
|
||||
"tarball": "http://registry.npmjs.org/hoek/-/hoek-2.14.0.tgz"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "hueniverse",
|
||||
|
@ -55,11 +54,7 @@
|
|||
"email": "quitlahok@gmail.com"
|
||||
}
|
||||
],
|
||||
"dist": {
|
||||
"shasum": "5d1196e0bf20c5cec957e8927101164effdaf1c9",
|
||||
"tarball": "http://registry.npmjs.org/hoek/-/hoek-2.12.0.tgz"
|
||||
},
|
||||
"directories": {},
|
||||
"_resolved": "https://registry.npmjs.org/hoek/-/hoek-2.12.0.tgz",
|
||||
"_resolved": "https://registry.npmjs.org/hoek/-/hoek-2.14.0.tgz",
|
||||
"readme": "ERROR: No README data found!"
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -12,7 +12,7 @@
|
|||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/globesherpa/node-isemail.git"
|
||||
"url": "git+https://github.com/globesherpa/node-isemail.git"
|
||||
},
|
||||
"homepage": "https://github.com/globesherpa/node-isemail",
|
||||
"bugs": {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Copyright (c) 2011-2014 Tim Wood, Iskren Chernev, Moment.js contributors
|
||||
Copyright (c) 2011-2015 Tim Wood, Iskren Chernev, Moment.js contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
[](https://gitter.im/moment/moment?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
|
||||
[![NPM version][npm-version-image]][npm-url] [![NPM downloads][npm-downloads-image]][npm-url] [![MIT License][license-image]][license-url] [![Build Status][travis-image]][travis-url]
|
||||
|
||||
A lightweight JavaScript date library for parsing, validating, manipulating, and formatting dates.
|
||||
|
|
|
@ -75,7 +75,7 @@
|
|||
longDateFormat : {
|
||||
LT : 'HH:mm',
|
||||
LTS : 'HH:mm:ss',
|
||||
L : 'DD/MM/YYYY',
|
||||
L : 'D/\u200FM/\u200FYYYY',
|
||||
LL : 'D MMMM YYYY',
|
||||
LLL : 'D MMMM YYYY LT',
|
||||
LLLL : 'dddd D MMMM YYYY LT'
|
||||
|
@ -115,7 +115,7 @@
|
|||
yy : pluralize('y')
|
||||
},
|
||||
preparse: function (string) {
|
||||
return string.replace(/[١٢٣٤٥٦٧٨٩٠]/g, function (match) {
|
||||
return string.replace(/\u200f/g, '').replace(/[١٢٣٤٥٦٧٨٩٠]/g, function (match) {
|
||||
return numberMap[match];
|
||||
}).replace(/،/g, ',');
|
||||
},
|
||||
|
|
|
@ -10,47 +10,47 @@
|
|||
|
||||
|
||||
var cv = moment.defineLocale('cv', {
|
||||
months : 'кăрлач_нарăс_пуш_ака_май_çĕртме_утă_çурла_авăн_юпа_чӳк_раштав'.split('_'),
|
||||
monthsShort : 'кăр_нар_пуш_ака_май_çĕр_утă_çур_ав_юпа_чӳк_раш'.split('_'),
|
||||
weekdays : 'вырсарникун_тунтикун_ытларикун_юнкун_кĕçнерникун_эрнекун_шăматкун'.split('_'),
|
||||
weekdaysShort : 'выр_тун_ытл_юн_кĕç_эрн_шăм'.split('_'),
|
||||
weekdaysMin : 'вр_тн_ыт_юн_кç_эр_шм'.split('_'),
|
||||
months : 'кӑрлач_нарӑс_пуш_ака_май_ҫӗртме_утӑ_ҫурла_авӑн_юпа_чӳк_раштав'.split('_'),
|
||||
monthsShort : 'кӑр_нар_пуш_ака_май_ҫӗр_утӑ_ҫур_авн_юпа_чӳк_раш'.split('_'),
|
||||
weekdays : 'вырсарникун_тунтикун_ытларикун_юнкун_кӗҫнерникун_эрнекун_шӑматкун'.split('_'),
|
||||
weekdaysShort : 'выр_тун_ытл_юн_кӗҫ_эрн_шӑм'.split('_'),
|
||||
weekdaysMin : 'вр_тн_ыт_юн_кҫ_эр_шм'.split('_'),
|
||||
longDateFormat : {
|
||||
LT : 'HH:mm',
|
||||
LTS : 'LT:ss',
|
||||
L : 'DD-MM-YYYY',
|
||||
LL : 'YYYY [çулхи] MMMM [уйăхĕн] D[-мĕшĕ]',
|
||||
LLL : 'YYYY [çулхи] MMMM [уйăхĕн] D[-мĕшĕ], LT',
|
||||
LLLL : 'dddd, YYYY [çулхи] MMMM [уйăхĕн] D[-мĕшĕ], LT'
|
||||
LL : 'YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ]',
|
||||
LLL : 'YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ], LT',
|
||||
LLLL : 'dddd, YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ], LT'
|
||||
},
|
||||
calendar : {
|
||||
sameDay: '[Паян] LT [сехетре]',
|
||||
nextDay: '[Ыран] LT [сехетре]',
|
||||
lastDay: '[Ĕнер] LT [сехетре]',
|
||||
nextWeek: '[Çитес] dddd LT [сехетре]',
|
||||
lastWeek: '[Иртнĕ] dddd LT [сехетре]',
|
||||
lastDay: '[Ӗнер] LT [сехетре]',
|
||||
nextWeek: '[Ҫитес] dddd LT [сехетре]',
|
||||
lastWeek: '[Иртнӗ] dddd LT [сехетре]',
|
||||
sameElse: 'L'
|
||||
},
|
||||
relativeTime : {
|
||||
future : function (output) {
|
||||
var affix = /сехет$/i.exec(output) ? 'рен' : /çул$/i.exec(output) ? 'тан' : 'ран';
|
||||
var affix = /сехет$/i.exec(output) ? 'рен' : /ҫул$/i.exec(output) ? 'тан' : 'ран';
|
||||
return output + affix;
|
||||
},
|
||||
past : '%s каялла',
|
||||
s : 'пĕр-ик çеккунт',
|
||||
m : 'пĕр минут',
|
||||
s : 'пӗр-ик ҫеккунт',
|
||||
m : 'пӗр минут',
|
||||
mm : '%d минут',
|
||||
h : 'пĕр сехет',
|
||||
h : 'пӗр сехет',
|
||||
hh : '%d сехет',
|
||||
d : 'пĕр кун',
|
||||
d : 'пӗр кун',
|
||||
dd : '%d кун',
|
||||
M : 'пĕр уйăх',
|
||||
MM : '%d уйăх',
|
||||
y : 'пĕр çул',
|
||||
yy : '%d çул'
|
||||
M : 'пӗр уйӑх',
|
||||
MM : '%d уйӑх',
|
||||
y : 'пӗр ҫул',
|
||||
yy : '%d ҫул'
|
||||
},
|
||||
ordinalParse: /\d{1,2}-мĕш/,
|
||||
ordinal : '%d-мĕш',
|
||||
ordinalParse: /\d{1,2}-мӗш/,
|
||||
ordinal : '%d-мӗш',
|
||||
week : {
|
||||
dow : 1, // Monday is the first day of the week.
|
||||
doy : 7 // The week that contains Jan 1st is the first week of the year.
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
}(this, function (moment) { 'use strict';
|
||||
|
||||
|
||||
var monthsShortDot = 'ene._feb._mar._abr._may._jun._jul._ago._sep._oct._nov._dic.'.split('_'),
|
||||
monthsShort = 'ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic'.split('_');
|
||||
var monthsShortDot = 'Ene._Feb._Mar._Abr._May._Jun._Jul._Ago._Sep._Oct._Nov._Dic.'.split('_'),
|
||||
monthsShort = 'Ene_Feb_Mar_Abr_May_Jun_Jul_Ago_Sep_Oct_Nov_Dic'.split('_');
|
||||
|
||||
var es = moment.defineLocale('es', {
|
||||
months : 'enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre'.split('_'),
|
||||
months : 'Enero_Febrero_Marzo_Abril_Mayo_Junio_Julio_Agosto_Septiembre_Octubre_Noviembre_Diciembre'.split('_'),
|
||||
monthsShort : function (m, format) {
|
||||
if (/-MMM-/.test(format)) {
|
||||
return monthsShort[m.month()];
|
||||
|
@ -21,8 +21,8 @@
|
|||
return monthsShortDot[m.month()];
|
||||
}
|
||||
},
|
||||
weekdays : 'domingo_lunes_martes_miércoles_jueves_viernes_sábado'.split('_'),
|
||||
weekdaysShort : 'dom._lun._mar._mié._jue._vie._sáb.'.split('_'),
|
||||
weekdays : 'Domingo_Lunes_Martes_Miércoles_Jueves_Viernes_Sábado'.split('_'),
|
||||
weekdaysShort : 'Dom._Lun._Mar._Mié._Jue._Vie._Sáb.'.split('_'),
|
||||
weekdaysMin : 'Do_Lu_Ma_Mi_Ju_Vi_Sá'.split('_'),
|
||||
longDateFormat : {
|
||||
LT : 'H:mm',
|
||||
|
|
|
@ -63,8 +63,8 @@
|
|||
}
|
||||
|
||||
var hr = moment.defineLocale('hr', {
|
||||
months : 'sječanj_veljača_ožujak_travanj_svibanj_lipanj_srpanj_kolovoz_rujan_listopad_studeni_prosinac'.split('_'),
|
||||
monthsShort : 'sje._vel._ožu._tra._svi._lip._srp._kol._ruj._lis._stu._pro.'.split('_'),
|
||||
months : 'siječanj_veljača_ožujak_travanj_svibanj_lipanj_srpanj_kolovoz_rujan_listopad_studeni_prosinac'.split('_'),
|
||||
monthsShort : 'sij._velj._ožu._tra._svi._lip._srp._kol._ruj._lis._stu._pro.'.split('_'),
|
||||
weekdays : 'nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota'.split('_'),
|
||||
weekdaysShort : 'ned._pon._uto._sri._čet._pet._sub.'.split('_'),
|
||||
weekdaysMin : 'ne_po_ut_sr_če_pe_su'.split('_'),
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
//! moment.js locale configuration
|
||||
//! locale : Boso Jowo (jv)
|
||||
//! author : Rony Lantip : https://github.com/lantip
|
||||
//! reference: http://jv.wikipedia.org/wiki/Basa_Jawa
|
||||
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
|
||||
typeof define === 'function' && define.amd ? define(['moment'], factory) :
|
||||
factory(global.moment)
|
||||
}(this, function (moment) { 'use strict';
|
||||
|
||||
|
||||
var jv = moment.defineLocale('jv', {
|
||||
months : 'Januari_Februari_Maret_April_Mei_Juni_Juli_Agustus_September_Oktober_Nopember_Desember'.split('_'),
|
||||
monthsShort : 'Jan_Feb_Mar_Apr_Mei_Jun_Jul_Ags_Sep_Okt_Nop_Des'.split('_'),
|
||||
weekdays : 'Minggu_Senen_Seloso_Rebu_Kemis_Jemuwah_Septu'.split('_'),
|
||||
weekdaysShort : 'Min_Sen_Sel_Reb_Kem_Jem_Sep'.split('_'),
|
||||
weekdaysMin : 'Mg_Sn_Sl_Rb_Km_Jm_Sp'.split('_'),
|
||||
longDateFormat : {
|
||||
LT : 'HH.mm',
|
||||
LTS : 'LT.ss',
|
||||
L : 'DD/MM/YYYY',
|
||||
LL : 'D MMMM YYYY',
|
||||
LLL : 'D MMMM YYYY [pukul] LT',
|
||||
LLLL : 'dddd, D MMMM YYYY [pukul] LT'
|
||||
},
|
||||
meridiemParse: /enjing|siyang|sonten|ndalu/,
|
||||
meridiemHour : function (hour, meridiem) {
|
||||
if (hour === 12) {
|
||||
hour = 0;
|
||||
}
|
||||
if (meridiem === 'enjing') {
|
||||
return hour;
|
||||
} else if (meridiem === 'siyang') {
|
||||
return hour >= 11 ? hour : hour + 12;
|
||||
} else if (meridiem === 'sonten' || meridiem === 'ndalu') {
|
||||
return hour + 12;
|
||||
}
|
||||
},
|
||||
meridiem : function (hours, minutes, isLower) {
|
||||
if (hours < 11) {
|
||||
return 'enjing';
|
||||
} else if (hours < 15) {
|
||||
return 'siyang';
|
||||
} else if (hours < 19) {
|
||||
return 'sonten';
|
||||
} else {
|
||||
return 'ndalu';
|
||||
}
|
||||
},
|
||||
calendar : {
|
||||
sameDay : '[Dinten puniko pukul] LT',
|
||||
nextDay : '[Mbenjang pukul] LT',
|
||||
nextWeek : 'dddd [pukul] LT',
|
||||
lastDay : '[Kala wingi pukul] LT',
|
||||
lastWeek : 'dddd [kepengker pukul] LT',
|
||||
sameElse : 'L'
|
||||
},
|
||||
relativeTime : {
|
||||
future : 'wonten ing %s',
|
||||
past : '%s ingkang kepengker',
|
||||
s : 'sawetawis detik',
|
||||
m : 'setunggal menit',
|
||||
mm : '%d menit',
|
||||
h : 'setunggal jam',
|
||||
hh : '%d jam',
|
||||
d : 'sedinten',
|
||||
dd : '%d dinten',
|
||||
M : 'sewulan',
|
||||
MM : '%d wulan',
|
||||
y : 'setaun',
|
||||
yy : '%d taun'
|
||||
},
|
||||
week : {
|
||||
dow : 1, // Monday is the first day of the week.
|
||||
doy : 7 // The week that contains Jan 1st is the first week of the year.
|
||||
}
|
||||
});
|
||||
|
||||
return jv;
|
||||
|
||||
}));
|
|
@ -1,6 +1,7 @@
|
|||
//! moment.js locale configuration
|
||||
//! locale : latvian (lv)
|
||||
//! author : Kristaps Karlsons : https://github.com/skakri
|
||||
//! author : Jānis Elmeris : https://github.com/JanisE
|
||||
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
|
||||
|
@ -10,23 +11,39 @@
|
|||
|
||||
|
||||
var units = {
|
||||
'mm': 'minūti_minūtes_minūte_minūtes',
|
||||
'hh': 'stundu_stundas_stunda_stundas',
|
||||
'dd': 'dienu_dienas_diena_dienas',
|
||||
'MM': 'mēnesi_mēnešus_mēnesis_mēneši',
|
||||
'yy': 'gadu_gadus_gads_gadi'
|
||||
'm': 'minūtes_minūtēm_minūte_minūtes'.split('_'),
|
||||
'mm': 'minūtes_minūtēm_minūte_minūtes'.split('_'),
|
||||
'h': 'stundas_stundām_stunda_stundas'.split('_'),
|
||||
'hh': 'stundas_stundām_stunda_stundas'.split('_'),
|
||||
'd': 'dienas_dienām_diena_dienas'.split('_'),
|
||||
'dd': 'dienas_dienām_diena_dienas'.split('_'),
|
||||
'M': 'mēneša_mēnešiem_mēnesis_mēneši'.split('_'),
|
||||
'MM': 'mēneša_mēnešiem_mēnesis_mēneši'.split('_'),
|
||||
'y': 'gada_gadiem_gads_gadi'.split('_'),
|
||||
'yy': 'gada_gadiem_gads_gadi'.split('_')
|
||||
};
|
||||
function format(word, number, withoutSuffix) {
|
||||
var forms = word.split('_');
|
||||
/**
|
||||
* @param withoutSuffix boolean true = a length of time; false = before/after a period of time.
|
||||
*/
|
||||
function format(forms, number, withoutSuffix) {
|
||||
if (withoutSuffix) {
|
||||
// E.g. "21 minūte", "3 minūtes".
|
||||
return number % 10 === 1 && number !== 11 ? forms[2] : forms[3];
|
||||
} else {
|
||||
// E.g. "21 minūtes" as in "pēc 21 minūtes".
|
||||
// E.g. "3 minūtēm" as in "pēc 3 minūtēm".
|
||||
return number % 10 === 1 && number !== 11 ? forms[0] : forms[1];
|
||||
}
|
||||
}
|
||||
function relativeTimeWithPlural(number, withoutSuffix, key) {
|
||||
return number + ' ' + format(units[key], number, withoutSuffix);
|
||||
}
|
||||
function relativeTimeWithSingular(number, withoutSuffix, key) {
|
||||
return format(units[key], number, withoutSuffix);
|
||||
}
|
||||
function relativeSeconds(number, withoutSuffix) {
|
||||
return withoutSuffix ? 'dažas sekundes' : 'dažām sekundēm';
|
||||
}
|
||||
|
||||
var lv = moment.defineLocale('lv', {
|
||||
months : 'janvāris_februāris_marts_aprīlis_maijs_jūnijs_jūlijs_augusts_septembris_oktobris_novembris_decembris'.split('_'),
|
||||
|
@ -37,7 +54,7 @@
|
|||
longDateFormat : {
|
||||
LT : 'HH:mm',
|
||||
LTS : 'LT:ss',
|
||||
L : 'DD.MM.YYYY',
|
||||
L : 'DD.MM.YYYY.',
|
||||
LL : 'YYYY. [gada] D. MMMM',
|
||||
LLL : 'YYYY. [gada] D. MMMM, LT',
|
||||
LLLL : 'YYYY. [gada] D. MMMM, dddd, LT'
|
||||
|
@ -51,18 +68,18 @@
|
|||
sameElse : 'L'
|
||||
},
|
||||
relativeTime : {
|
||||
future : '%s vēlāk',
|
||||
past : '%s agrāk',
|
||||
s : 'dažas sekundes',
|
||||
m : 'minūti',
|
||||
future : 'pēc %s',
|
||||
past : 'pirms %s',
|
||||
s : relativeSeconds,
|
||||
m : relativeTimeWithSingular,
|
||||
mm : relativeTimeWithPlural,
|
||||
h : 'stundu',
|
||||
h : relativeTimeWithSingular,
|
||||
hh : relativeTimeWithPlural,
|
||||
d : 'dienu',
|
||||
d : relativeTimeWithSingular,
|
||||
dd : relativeTimeWithPlural,
|
||||
M : 'mēnesi',
|
||||
M : relativeTimeWithSingular,
|
||||
MM : relativeTimeWithPlural,
|
||||
y : 'gadu',
|
||||
y : relativeTimeWithSingular,
|
||||
yy : relativeTimeWithPlural
|
||||
},
|
||||
ordinalParse: /\d{1,2}\./,
|
||||
|
|
|
@ -0,0 +1,108 @@
|
|||
//! moment.js locale configuration
|
||||
//! locale : Montenegrin (me)
|
||||
//! author : Miodrag Nikač <miodrag@restartit.me> : https://github.com/miodragnikac
|
||||
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
|
||||
typeof define === 'function' && define.amd ? define(['moment'], factory) :
|
||||
factory(global.moment)
|
||||
}(this, function (moment) { 'use strict';
|
||||
|
||||
|
||||
var translator = {
|
||||
words: { //Different grammatical cases
|
||||
m: ['jedan minut', 'jednog minuta'],
|
||||
mm: ['minut', 'minuta', 'minuta'],
|
||||
h: ['jedan sat', 'jednog sata'],
|
||||
hh: ['sat', 'sata', 'sati'],
|
||||
dd: ['dan', 'dana', 'dana'],
|
||||
MM: ['mjesec', 'mjeseca', 'mjeseci'],
|
||||
yy: ['godina', 'godine', 'godina']
|
||||
},
|
||||
correctGrammaticalCase: function (number, wordKey) {
|
||||
return number === 1 ? wordKey[0] : (number >= 2 && number <= 4 ? wordKey[1] : wordKey[2]);
|
||||
},
|
||||
translate: function (number, withoutSuffix, key) {
|
||||
var wordKey = translator.words[key];
|
||||
if (key.length === 1) {
|
||||
return withoutSuffix ? wordKey[0] : wordKey[1];
|
||||
} else {
|
||||
return number + ' ' + translator.correctGrammaticalCase(number, wordKey);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var me = moment.defineLocale('me', {
|
||||
months: ['januar', 'februar', 'mart', 'april', 'maj', 'jun', 'jul', 'avgust', 'septembar', 'oktobar', 'novembar', 'decembar'],
|
||||
monthsShort: ['jan.', 'feb.', 'mar.', 'apr.', 'maj', 'jun', 'jul', 'avg.', 'sep.', 'okt.', 'nov.', 'dec.'],
|
||||
weekdays: ['nedjelja', 'ponedjeljak', 'utorak', 'srijeda', 'četvrtak', 'petak', 'subota'],
|
||||
weekdaysShort: ['ned.', 'pon.', 'uto.', 'sri.', 'čet.', 'pet.', 'sub.'],
|
||||
weekdaysMin: ['ne', 'po', 'ut', 'sr', 'če', 'pe', 'su'],
|
||||
longDateFormat: {
|
||||
LT: 'H:mm',
|
||||
LTS : 'LT:ss',
|
||||
L: 'DD. MM. YYYY',
|
||||
LL: 'D. MMMM YYYY',
|
||||
LLL: 'D. MMMM YYYY LT',
|
||||
LLLL: 'dddd, D. MMMM YYYY LT'
|
||||
},
|
||||
calendar: {
|
||||
sameDay: '[danas u] LT',
|
||||
nextDay: '[sjutra u] LT',
|
||||
|
||||
nextWeek: function () {
|
||||
switch (this.day()) {
|
||||
case 0:
|
||||
return '[u] [nedjelju] [u] LT';
|
||||
case 3:
|
||||
return '[u] [srijedu] [u] LT';
|
||||
case 6:
|
||||
return '[u] [subotu] [u] LT';
|
||||
case 1:
|
||||
case 2:
|
||||
case 4:
|
||||
case 5:
|
||||
return '[u] dddd [u] LT';
|
||||
}
|
||||
},
|
||||
lastDay : '[juče u] LT',
|
||||
lastWeek : function () {
|
||||
var lastWeekDays = [
|
||||
'[prošle] [nedjelje] [u] LT',
|
||||
'[prošlog] [ponedjeljka] [u] LT',
|
||||
'[prošlog] [utorka] [u] LT',
|
||||
'[prošle] [srijede] [u] LT',
|
||||
'[prošlog] [četvrtka] [u] LT',
|
||||
'[prošlog] [petka] [u] LT',
|
||||
'[prošle] [subote] [u] LT'
|
||||
];
|
||||
return lastWeekDays[this.day()];
|
||||
},
|
||||
sameElse : 'L'
|
||||
},
|
||||
relativeTime : {
|
||||
future : 'za %s',
|
||||
past : 'prije %s',
|
||||
s : 'nekoliko sekundi',
|
||||
m : translator.translate,
|
||||
mm : translator.translate,
|
||||
h : translator.translate,
|
||||
hh : translator.translate,
|
||||
d : 'dan',
|
||||
dd : translator.translate,
|
||||
M : 'mjesec',
|
||||
MM : translator.translate,
|
||||
y : 'godinu',
|
||||
yy : translator.translate
|
||||
},
|
||||
ordinalParse: /\d{1,2}\./,
|
||||
ordinal : '%d.',
|
||||
week : {
|
||||
dow : 1, // Monday is the first day of the week.
|
||||
doy : 7 // The week that contains Jan 1st is the first week of the year.
|
||||
}
|
||||
});
|
||||
|
||||
return me;
|
||||
|
||||
}));
|
|
@ -37,8 +37,9 @@
|
|||
months: 'ဇန်နဝါရီ_ဖေဖော်ဝါရီ_မတ်_ဧပြီ_မေ_ဇွန်_ဇူလိုင်_သြဂုတ်_စက်တင်ဘာ_အောက်တိုဘာ_နိုဝင်ဘာ_ဒီဇင်ဘာ'.split('_'),
|
||||
monthsShort: 'ဇန်_ဖေ_မတ်_ပြီ_မေ_ဇွန်_လိုင်_သြ_စက်_အောက်_နို_ဒီ'.split('_'),
|
||||
weekdays: 'တနင်္ဂနွေ_တနင်္လာ_အင်္ဂါ_ဗုဒ္ဓဟူး_ကြာသပတေး_သောကြာ_စနေ'.split('_'),
|
||||
weekdaysShort: 'နွေ_လာ_င်္ဂါ_ဟူး_ကြာ_သော_နေ'.split('_'),
|
||||
weekdaysMin: 'နွေ_လာ_င်္ဂါ_ဟူး_ကြာ_သော_နေ'.split('_'),
|
||||
weekdaysShort: 'နွေ_လာ_ဂါ_ဟူး_ကြာ_သော_နေ'.split('_'),
|
||||
weekdaysMin: 'နွေ_လာ_ဂါ_ဟူး_ကြာ_သော_နေ'.split('_'),
|
||||
|
||||
longDateFormat: {
|
||||
LT: 'HH:mm',
|
||||
LTS: 'HH:mm:ss',
|
||||
|
|
|
@ -34,7 +34,12 @@
|
|||
|
||||
var pl = moment.defineLocale('pl', {
|
||||
months : function (momentToFormat, format) {
|
||||
if (/D MMMM/.test(format)) {
|
||||
if (format === '') {
|
||||
// Hack: if format empty we know this is used to generate
|
||||
// RegExp by moment. Give then back both valid forms of months
|
||||
// in RegExp ready format.
|
||||
return '(' + monthsSubjective[momentToFormat.month()] + '|' + monthsNominative[momentToFormat.month()] + ')';
|
||||
} else if (/D MMMM/.test(format)) {
|
||||
return monthsSubjective[momentToFormat.month()];
|
||||
} else {
|
||||
return monthsNominative[momentToFormat.month()];
|
||||
|
|
|
@ -10,11 +10,11 @@
|
|||
|
||||
|
||||
var pt_br = moment.defineLocale('pt-br', {
|
||||
months : 'janeiro_fevereiro_março_abril_maio_junho_julho_agosto_setembro_outubro_novembro_dezembro'.split('_'),
|
||||
monthsShort : 'jan_fev_mar_abr_mai_jun_jul_ago_set_out_nov_dez'.split('_'),
|
||||
weekdays : 'domingo_segunda-feira_terça-feira_quarta-feira_quinta-feira_sexta-feira_sábado'.split('_'),
|
||||
weekdaysShort : 'dom_seg_ter_qua_qui_sex_sáb'.split('_'),
|
||||
weekdaysMin : 'dom_2ª_3ª_4ª_5ª_6ª_sáb'.split('_'),
|
||||
months : 'Janeiro_Fevereiro_Março_Abril_Maio_Junho_Julho_Agosto_Setembro_Outubro_Novembro_Dezembro'.split('_'),
|
||||
monthsShort : 'Jan_Fev_Mar_Abr_Mai_Jun_Jul_Ago_Set_Out_Nov_Dez'.split('_'),
|
||||
weekdays : 'Domingo_Segunda-Feira_Terça-Feira_Quarta-Feira_Quinta-Feira_Sexta-Feira_Sábado'.split('_'),
|
||||
weekdaysShort : 'Dom_Seg_Ter_Qua_Qui_Sex_Sáb'.split('_'),
|
||||
weekdaysMin : 'Dom_2ª_3ª_4ª_5ª_6ª_Sáb'.split('_'),
|
||||
longDateFormat : {
|
||||
LT : 'HH:mm',
|
||||
LTS : 'LT:ss',
|
||||
|
|
|
@ -10,11 +10,11 @@
|
|||
|
||||
|
||||
var pt = moment.defineLocale('pt', {
|
||||
months : 'janeiro_fevereiro_março_abril_maio_junho_julho_agosto_setembro_outubro_novembro_dezembro'.split('_'),
|
||||
monthsShort : 'jan_fev_mar_abr_mai_jun_jul_ago_set_out_nov_dez'.split('_'),
|
||||
weekdays : 'domingo_segunda-feira_terça-feira_quarta-feira_quinta-feira_sexta-feira_sábado'.split('_'),
|
||||
weekdaysShort : 'dom_seg_ter_qua_qui_sex_sáb'.split('_'),
|
||||
weekdaysMin : 'dom_2ª_3ª_4ª_5ª_6ª_sáb'.split('_'),
|
||||
months : 'Janeiro_Fevereiro_Março_Abril_Maio_Junho_Julho_Agosto_Setembro_Outubro_Novembro_Dezembro'.split('_'),
|
||||
monthsShort : 'Jan_Fev_Mar_Abr_Mai_Jun_Jul_Ago_Set_Out_Nov_Dez'.split('_'),
|
||||
weekdays : 'Domingo_Segunda-Feira_Terça-Feira_Quarta-Feira_Quinta-Feira_Sexta-Feira_Sábado'.split('_'),
|
||||
weekdaysShort : 'Dom_Seg_Ter_Qua_Qui_Sex_Sáb'.split('_'),
|
||||
weekdaysMin : 'Dom_2ª_3ª_4ª_5ª_6ª_Sáb'.split('_'),
|
||||
longDateFormat : {
|
||||
LT : 'HH:mm',
|
||||
LTS : 'LT:ss',
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
//! moment.js locale configuration
|
||||
//! locale : Sinhalese (si)
|
||||
//! author : Sampath Sitinamaluwa : https://github.com/sampathsris
|
||||
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
|
||||
typeof define === 'function' && define.amd ? define(['moment'], factory) :
|
||||
factory(global.moment)
|
||||
}(this, function (moment) { 'use strict';
|
||||
|
||||
|
||||
var si = moment.defineLocale('si', {
|
||||
months : 'ජනවාරි_පෙබරවාරි_මාර්තු_අප්රේල්_මැයි_ජූනි_ජූලි_අගෝස්තු_සැප්තැම්බර්_ඔක්තෝබර්_නොවැම්බර්_දෙසැම්බර්'.split('_'),
|
||||
monthsShort : 'ජන_පෙබ_මාර්_අප්_මැයි_ජූනි_ජූලි_අගෝ_සැප්_ඔක්_නොවැ_දෙසැ'.split('_'),
|
||||
weekdays : 'ඉරිදා_සඳුදා_අඟහරුවාදා_බදාදා_බ්රහස්පතින්දා_සිකුරාදා_සෙනසුරාදා'.split('_'),
|
||||
weekdaysShort : 'ඉරි_සඳු_අඟ_බදා_බ්රහ_සිකු_සෙන'.split('_'),
|
||||
weekdaysMin : 'ඉ_ස_අ_බ_බ්ර_සි_සෙ'.split('_'),
|
||||
longDateFormat : {
|
||||
LT : 'a h:mm',
|
||||
LTS : 'a h:mm:ss',
|
||||
L : 'YYYY/MM/DD',
|
||||
LL : 'YYYY MMMM D',
|
||||
LLL : 'YYYY MMMM D, LT',
|
||||
LLLL : 'YYYY MMMM D [වැනි] dddd, LTS'
|
||||
},
|
||||
calendar : {
|
||||
sameDay : '[අද] LT[ට]',
|
||||
nextDay : '[හෙට] LT[ට]',
|
||||
nextWeek : 'dddd LT[ට]',
|
||||
lastDay : '[ඊයේ] LT[ට]',
|
||||
lastWeek : '[පසුගිය] dddd LT[ට]',
|
||||
sameElse : 'L'
|
||||
},
|
||||
relativeTime : {
|
||||
future : '%sකින්',
|
||||
past : '%sකට පෙර',
|
||||
s : 'තත්පර කිහිපය',
|
||||
m : 'මිනිත්තුව',
|
||||
mm : 'මිනිත්තු %d',
|
||||
h : 'පැය',
|
||||
hh : 'පැය %d',
|
||||
d : 'දිනය',
|
||||
dd : 'දින %d',
|
||||
M : 'මාසය',
|
||||
MM : 'මාස %d',
|
||||
y : 'වසර',
|
||||
yy : 'වසර %d'
|
||||
},
|
||||
ordinalParse: /\d{1,2} වැනි/,
|
||||
ordinal : function (number) {
|
||||
return number + ' වැනි';
|
||||
},
|
||||
meridiem : function (hours, minutes, isLower) {
|
||||
if (hours > 11) {
|
||||
return isLower ? 'ප.ව.' : 'පස් වරු';
|
||||
} else {
|
||||
return isLower ? 'පෙ.ව.' : 'පෙර වරු';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return si;
|
||||
|
||||
}));
|
|
@ -9,62 +9,72 @@
|
|||
}(this, function (moment) { 'use strict';
|
||||
|
||||
|
||||
function translate(number, withoutSuffix, key) {
|
||||
function processRelativeTime(number, withoutSuffix, key, isFuture) {
|
||||
var result = number + ' ';
|
||||
switch (key) {
|
||||
case 's':
|
||||
return withoutSuffix || isFuture ? 'nekaj sekund' : 'nekaj sekundami';
|
||||
case 'm':
|
||||
return withoutSuffix ? 'ena minuta' : 'eno minuto';
|
||||
case 'mm':
|
||||
if (number === 1) {
|
||||
result += 'minuta';
|
||||
result += withoutSuffix ? 'minuta' : 'minuto';
|
||||
} else if (number === 2) {
|
||||
result += 'minuti';
|
||||
} else if (number === 3 || number === 4) {
|
||||
result += 'minute';
|
||||
result += withoutSuffix || isFuture ? 'minuti' : 'minutama';
|
||||
} else if (number < 5) {
|
||||
result += withoutSuffix || isFuture ? 'minute' : 'minutami';
|
||||
} else {
|
||||
result += 'minut';
|
||||
result += withoutSuffix || isFuture ? 'minut' : 'minutami';
|
||||
}
|
||||
return result;
|
||||
case 'h':
|
||||
return withoutSuffix ? 'ena ura' : 'eno uro';
|
||||
case 'hh':
|
||||
if (number === 1) {
|
||||
result += 'ura';
|
||||
result += withoutSuffix ? 'ura' : 'uro';
|
||||
} else if (number === 2) {
|
||||
result += 'uri';
|
||||
} else if (number === 3 || number === 4) {
|
||||
result += 'ure';
|
||||
result += withoutSuffix || isFuture ? 'uri' : 'urama';
|
||||
} else if (number < 5) {
|
||||
result += withoutSuffix || isFuture ? 'ure' : 'urami';
|
||||
} else {
|
||||
result += 'ur';
|
||||
result += withoutSuffix || isFuture ? 'ur' : 'urami';
|
||||
}
|
||||
return result;
|
||||
case 'd':
|
||||
return withoutSuffix || isFuture ? 'en dan' : 'enim dnem';
|
||||
case 'dd':
|
||||
if (number === 1) {
|
||||
result += 'dan';
|
||||
result += withoutSuffix || isFuture ? 'dan' : 'dnem';
|
||||
} else if (number === 2) {
|
||||
result += withoutSuffix || isFuture ? 'dni' : 'dnevoma';
|
||||
} else {
|
||||
result += 'dni';
|
||||
result += withoutSuffix || isFuture ? 'dni' : 'dnevi';
|
||||
}
|
||||
return result;
|
||||
case 'M':
|
||||
return withoutSuffix || isFuture ? 'en mesec' : 'enim mesecem';
|
||||
case 'MM':
|
||||
if (number === 1) {
|
||||
result += 'mesec';
|
||||
result += withoutSuffix || isFuture ? 'mesec' : 'mesecem';
|
||||
} else if (number === 2) {
|
||||
result += 'meseca';
|
||||
} else if (number === 3 || number === 4) {
|
||||
result += 'mesece';
|
||||
result += withoutSuffix || isFuture ? 'meseca' : 'mesecema';
|
||||
} else if (number < 5) {
|
||||
result += withoutSuffix || isFuture ? 'mesece' : 'meseci';
|
||||
} else {
|
||||
result += 'mesecev';
|
||||
result += withoutSuffix || isFuture ? 'mesecev' : 'meseci';
|
||||
}
|
||||
return result;
|
||||
case 'y':
|
||||
return withoutSuffix || isFuture ? 'eno leto' : 'enim letom';
|
||||
case 'yy':
|
||||
if (number === 1) {
|
||||
result += 'leto';
|
||||
result += withoutSuffix || isFuture ? 'leto' : 'letom';
|
||||
} else if (number === 2) {
|
||||
result += 'leti';
|
||||
} else if (number === 3 || number === 4) {
|
||||
result += 'leta';
|
||||
result += withoutSuffix || isFuture ? 'leti' : 'letoma';
|
||||
} else if (number < 5) {
|
||||
result += withoutSuffix || isFuture ? 'leta' : 'leti';
|
||||
} else {
|
||||
result += 'let';
|
||||
result += withoutSuffix || isFuture ? 'let' : 'leti';
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -87,6 +97,7 @@
|
|||
calendar : {
|
||||
sameDay : '[danes ob] LT',
|
||||
nextDay : '[jutri ob] LT',
|
||||
|
||||
nextWeek : function () {
|
||||
switch (this.day()) {
|
||||
case 0:
|
||||
|
@ -106,9 +117,11 @@
|
|||
lastWeek : function () {
|
||||
switch (this.day()) {
|
||||
case 0:
|
||||
return '[prejšnjo] [nedeljo] [ob] LT';
|
||||
case 3:
|
||||
return '[prejšnjo] [sredo] [ob] LT';
|
||||
case 6:
|
||||
return '[prejšnja] dddd [ob] LT';
|
||||
return '[prejšnjo] [soboto] [ob] LT';
|
||||
case 1:
|
||||
case 2:
|
||||
case 4:
|
||||
|
@ -120,18 +133,18 @@
|
|||
},
|
||||
relativeTime : {
|
||||
future : 'čez %s',
|
||||
past : '%s nazaj',
|
||||
s : 'nekaj sekund',
|
||||
m : translate,
|
||||
mm : translate,
|
||||
h : translate,
|
||||
hh : translate,
|
||||
d : 'en dan',
|
||||
dd : translate,
|
||||
M : 'en mesec',
|
||||
MM : translate,
|
||||
y : 'eno leto',
|
||||
yy : translate
|
||||
past : 'pred %s',
|
||||
s : processRelativeTime,
|
||||
m : processRelativeTime,
|
||||
mm : processRelativeTime,
|
||||
h : processRelativeTime,
|
||||
hh : processRelativeTime,
|
||||
d : processRelativeTime,
|
||||
dd : processRelativeTime,
|
||||
M : processRelativeTime,
|
||||
MM : processRelativeTime,
|
||||
y : processRelativeTime,
|
||||
yy : processRelativeTime
|
||||
},
|
||||
ordinalParse: /\d{1,2}\./,
|
||||
ordinal : '%d.',
|
||||
|
|
|
@ -27,8 +27,8 @@
|
|||
sameDay: '[Idag] LT',
|
||||
nextDay: '[Imorgon] LT',
|
||||
lastDay: '[Igår] LT',
|
||||
nextWeek: 'dddd LT',
|
||||
lastWeek: '[Förra] dddd[en] LT',
|
||||
nextWeek: '[På] dddd LT',
|
||||
lastWeek: '[I] dddd[s] LT',
|
||||
sameElse: 'L'
|
||||
},
|
||||
relativeTime : {
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
weekdaysShort : '周日_周一_周二_周三_周四_周五_周六'.split('_'),
|
||||
weekdaysMin : '日_一_二_三_四_五_六'.split('_'),
|
||||
longDateFormat : {
|
||||
LT : 'Ah点mm',
|
||||
LT : 'Ah点mm分',
|
||||
LTS : 'Ah点m分s秒',
|
||||
L : 'YYYY-MM-DD',
|
||||
LL : 'YYYY年MMMD日',
|
||||
|
@ -103,16 +103,16 @@
|
|||
future : '%s内',
|
||||
past : '%s前',
|
||||
s : '几秒',
|
||||
m : '1分钟',
|
||||
mm : '%d分钟',
|
||||
h : '1小时',
|
||||
hh : '%d小时',
|
||||
d : '1天',
|
||||
dd : '%d天',
|
||||
M : '1个月',
|
||||
MM : '%d个月',
|
||||
y : '1年',
|
||||
yy : '%d年'
|
||||
m : '1 分钟',
|
||||
mm : '%d 分钟',
|
||||
h : '1 小时',
|
||||
hh : '%d 小时',
|
||||
d : '1 天',
|
||||
dd : '%d 天',
|
||||
M : '1 个月',
|
||||
MM : '%d 个月',
|
||||
y : '1 年',
|
||||
yy : '%d 年'
|
||||
},
|
||||
week : {
|
||||
// GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
weekdaysShort : '週日_週一_週二_週三_週四_週五_週六'.split('_'),
|
||||
weekdaysMin : '日_一_二_三_四_五_六'.split('_'),
|
||||
longDateFormat : {
|
||||
LT : 'Ah點mm',
|
||||
LT : 'Ah點mm分',
|
||||
LTS : 'Ah點m分s秒',
|
||||
L : 'YYYY年MMMD日',
|
||||
LL : 'YYYY年MMMD日',
|
||||
|
|
|
@ -322,7 +322,7 @@
|
|||
longDateFormat : {
|
||||
LT : 'HH:mm',
|
||||
LTS : 'HH:mm:ss',
|
||||
L : 'DD/MM/YYYY',
|
||||
L : 'D/\u200FM/\u200FYYYY',
|
||||
LL : 'D MMMM YYYY',
|
||||
LLL : 'D MMMM YYYY LT',
|
||||
LLLL : 'dddd D MMMM YYYY LT'
|
||||
|
@ -362,7 +362,7 @@
|
|||
yy : pluralize('y')
|
||||
},
|
||||
preparse: function (string) {
|
||||
return string.replace(/[١٢٣٤٥٦٧٨٩٠]/g, function (match) {
|
||||
return string.replace(/\u200f/g, '').replace(/[١٢٣٤٥٦٧٨٩٠]/g, function (match) {
|
||||
return ar__numberMap[match];
|
||||
}).replace(/،/g, ',');
|
||||
},
|
||||
|
@ -1331,47 +1331,47 @@
|
|||
//! author : Anatoly Mironov : https://github.com/mirontoli
|
||||
|
||||
var cv = moment.defineLocale('cv', {
|
||||
months : 'кăрлач_нарăс_пуш_ака_май_çĕртме_утă_çурла_авăн_юпа_чӳк_раштав'.split('_'),
|
||||
monthsShort : 'кăр_нар_пуш_ака_май_çĕр_утă_çур_ав_юпа_чӳк_раш'.split('_'),
|
||||
weekdays : 'вырсарникун_тунтикун_ытларикун_юнкун_кĕçнерникун_эрнекун_шăматкун'.split('_'),
|
||||
weekdaysShort : 'выр_тун_ытл_юн_кĕç_эрн_шăм'.split('_'),
|
||||
weekdaysMin : 'вр_тн_ыт_юн_кç_эр_шм'.split('_'),
|
||||
months : 'кӑрлач_нарӑс_пуш_ака_май_ҫӗртме_утӑ_ҫурла_авӑн_юпа_чӳк_раштав'.split('_'),
|
||||
monthsShort : 'кӑр_нар_пуш_ака_май_ҫӗр_утӑ_ҫур_авн_юпа_чӳк_раш'.split('_'),
|
||||
weekdays : 'вырсарникун_тунтикун_ытларикун_юнкун_кӗҫнерникун_эрнекун_шӑматкун'.split('_'),
|
||||
weekdaysShort : 'выр_тун_ытл_юн_кӗҫ_эрн_шӑм'.split('_'),
|
||||
weekdaysMin : 'вр_тн_ыт_юн_кҫ_эр_шм'.split('_'),
|
||||
longDateFormat : {
|
||||
LT : 'HH:mm',
|
||||
LTS : 'LT:ss',
|
||||
L : 'DD-MM-YYYY',
|
||||
LL : 'YYYY [çулхи] MMMM [уйăхĕн] D[-мĕшĕ]',
|
||||
LLL : 'YYYY [çулхи] MMMM [уйăхĕн] D[-мĕшĕ], LT',
|
||||
LLLL : 'dddd, YYYY [çулхи] MMMM [уйăхĕн] D[-мĕшĕ], LT'
|
||||
LL : 'YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ]',
|
||||
LLL : 'YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ], LT',
|
||||
LLLL : 'dddd, YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ], LT'
|
||||
},
|
||||
calendar : {
|
||||
sameDay: '[Паян] LT [сехетре]',
|
||||
nextDay: '[Ыран] LT [сехетре]',
|
||||
lastDay: '[Ĕнер] LT [сехетре]',
|
||||
nextWeek: '[Çитес] dddd LT [сехетре]',
|
||||
lastWeek: '[Иртнĕ] dddd LT [сехетре]',
|
||||
lastDay: '[Ӗнер] LT [сехетре]',
|
||||
nextWeek: '[Ҫитес] dddd LT [сехетре]',
|
||||
lastWeek: '[Иртнӗ] dddd LT [сехетре]',
|
||||
sameElse: 'L'
|
||||
},
|
||||
relativeTime : {
|
||||
future : function (output) {
|
||||
var affix = /сехет$/i.exec(output) ? 'рен' : /çул$/i.exec(output) ? 'тан' : 'ран';
|
||||
var affix = /сехет$/i.exec(output) ? 'рен' : /ҫул$/i.exec(output) ? 'тан' : 'ран';
|
||||
return output + affix;
|
||||
},
|
||||
past : '%s каялла',
|
||||
s : 'пĕр-ик çеккунт',
|
||||
m : 'пĕр минут',
|
||||
s : 'пӗр-ик ҫеккунт',
|
||||
m : 'пӗр минут',
|
||||
mm : '%d минут',
|
||||
h : 'пĕр сехет',
|
||||
h : 'пӗр сехет',
|
||||
hh : '%d сехет',
|
||||
d : 'пĕр кун',
|
||||
d : 'пӗр кун',
|
||||
dd : '%d кун',
|
||||
M : 'пĕр уйăх',
|
||||
MM : '%d уйăх',
|
||||
y : 'пĕр çул',
|
||||
yy : '%d çул'
|
||||
M : 'пӗр уйӑх',
|
||||
MM : '%d уйӑх',
|
||||
y : 'пӗр ҫул',
|
||||
yy : '%d ҫул'
|
||||
},
|
||||
ordinalParse: /\d{1,2}-мĕш/,
|
||||
ordinal : '%d-мĕш',
|
||||
ordinalParse: /\d{1,2}-мӗш/,
|
||||
ordinal : '%d-мӗш',
|
||||
week : {
|
||||
dow : 1, // Monday is the first day of the week.
|
||||
doy : 7 // The week that contains Jan 1st is the first week of the year.
|
||||
|
@ -1936,11 +1936,11 @@
|
|||
//! locale : spanish (es)
|
||||
//! author : Julio Napurí : https://github.com/julionc
|
||||
|
||||
var monthsShortDot = 'ene._feb._mar._abr._may._jun._jul._ago._sep._oct._nov._dic.'.split('_'),
|
||||
es__monthsShort = 'ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic'.split('_');
|
||||
var monthsShortDot = 'Ene._Feb._Mar._Abr._May._Jun._Jul._Ago._Sep._Oct._Nov._Dic.'.split('_'),
|
||||
es__monthsShort = 'Ene_Feb_Mar_Abr_May_Jun_Jul_Ago_Sep_Oct_Nov_Dic'.split('_');
|
||||
|
||||
var es = moment.defineLocale('es', {
|
||||
months : 'enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre'.split('_'),
|
||||
months : 'Enero_Febrero_Marzo_Abril_Mayo_Junio_Julio_Agosto_Septiembre_Octubre_Noviembre_Diciembre'.split('_'),
|
||||
monthsShort : function (m, format) {
|
||||
if (/-MMM-/.test(format)) {
|
||||
return es__monthsShort[m.month()];
|
||||
|
@ -1948,8 +1948,8 @@
|
|||
return monthsShortDot[m.month()];
|
||||
}
|
||||
},
|
||||
weekdays : 'domingo_lunes_martes_miércoles_jueves_viernes_sábado'.split('_'),
|
||||
weekdaysShort : 'dom._lun._mar._mié._jue._vie._sáb.'.split('_'),
|
||||
weekdays : 'Domingo_Lunes_Martes_Miércoles_Jueves_Viernes_Sábado'.split('_'),
|
||||
weekdaysShort : 'Dom._Lun._Mar._Mié._Jue._Vie._Sáb.'.split('_'),
|
||||
weekdaysMin : 'Do_Lu_Ma_Mi_Ju_Vi_Sá'.split('_'),
|
||||
longDateFormat : {
|
||||
LT : 'H:mm',
|
||||
|
@ -2824,8 +2824,8 @@
|
|||
}
|
||||
|
||||
var hr = moment.defineLocale('hr', {
|
||||
months : 'sječanj_veljača_ožujak_travanj_svibanj_lipanj_srpanj_kolovoz_rujan_listopad_studeni_prosinac'.split('_'),
|
||||
monthsShort : 'sje._vel._ožu._tra._svi._lip._srp._kol._ruj._lis._stu._pro.'.split('_'),
|
||||
months : 'siječanj_veljača_ožujak_travanj_svibanj_lipanj_srpanj_kolovoz_rujan_listopad_studeni_prosinac'.split('_'),
|
||||
monthsShort : 'sij._velj._ožu._tra._svi._lip._srp._kol._ruj._lis._stu._pro.'.split('_'),
|
||||
weekdays : 'nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota'.split('_'),
|
||||
weekdaysShort : 'ned._pon._uto._sri._čet._pet._sub.'.split('_'),
|
||||
weekdaysMin : 'ne_po_ut_sr_če_pe_su'.split('_'),
|
||||
|
@ -3394,6 +3394,78 @@
|
|||
}
|
||||
});
|
||||
|
||||
//! moment.js locale configuration
|
||||
//! locale : Boso Jowo (jv)
|
||||
//! author : Rony Lantip : https://github.com/lantip
|
||||
//! reference: http://jv.wikipedia.org/wiki/Basa_Jawa
|
||||
|
||||
var jv = moment.defineLocale('jv', {
|
||||
months : 'Januari_Februari_Maret_April_Mei_Juni_Juli_Agustus_September_Oktober_Nopember_Desember'.split('_'),
|
||||
monthsShort : 'Jan_Feb_Mar_Apr_Mei_Jun_Jul_Ags_Sep_Okt_Nop_Des'.split('_'),
|
||||
weekdays : 'Minggu_Senen_Seloso_Rebu_Kemis_Jemuwah_Septu'.split('_'),
|
||||
weekdaysShort : 'Min_Sen_Sel_Reb_Kem_Jem_Sep'.split('_'),
|
||||
weekdaysMin : 'Mg_Sn_Sl_Rb_Km_Jm_Sp'.split('_'),
|
||||
longDateFormat : {
|
||||
LT : 'HH.mm',
|
||||
LTS : 'LT.ss',
|
||||
L : 'DD/MM/YYYY',
|
||||
LL : 'D MMMM YYYY',
|
||||
LLL : 'D MMMM YYYY [pukul] LT',
|
||||
LLLL : 'dddd, D MMMM YYYY [pukul] LT'
|
||||
},
|
||||
meridiemParse: /enjing|siyang|sonten|ndalu/,
|
||||
meridiemHour : function (hour, meridiem) {
|
||||
if (hour === 12) {
|
||||
hour = 0;
|
||||
}
|
||||
if (meridiem === 'enjing') {
|
||||
return hour;
|
||||
} else if (meridiem === 'siyang') {
|
||||
return hour >= 11 ? hour : hour + 12;
|
||||
} else if (meridiem === 'sonten' || meridiem === 'ndalu') {
|
||||
return hour + 12;
|
||||
}
|
||||
},
|
||||
meridiem : function (hours, minutes, isLower) {
|
||||
if (hours < 11) {
|
||||
return 'enjing';
|
||||
} else if (hours < 15) {
|
||||
return 'siyang';
|
||||
} else if (hours < 19) {
|
||||
return 'sonten';
|
||||
} else {
|
||||
return 'ndalu';
|
||||
}
|
||||
},
|
||||
calendar : {
|
||||
sameDay : '[Dinten puniko pukul] LT',
|
||||
nextDay : '[Mbenjang pukul] LT',
|
||||
nextWeek : 'dddd [pukul] LT',
|
||||
lastDay : '[Kala wingi pukul] LT',
|
||||
lastWeek : 'dddd [kepengker pukul] LT',
|
||||
sameElse : 'L'
|
||||
},
|
||||
relativeTime : {
|
||||
future : 'wonten ing %s',
|
||||
past : '%s ingkang kepengker',
|
||||
s : 'sawetawis detik',
|
||||
m : 'setunggal menit',
|
||||
mm : '%d menit',
|
||||
h : 'setunggal jam',
|
||||
hh : '%d jam',
|
||||
d : 'sedinten',
|
||||
dd : '%d dinten',
|
||||
M : 'sewulan',
|
||||
MM : '%d wulan',
|
||||
y : 'setaun',
|
||||
yy : '%d taun'
|
||||
},
|
||||
week : {
|
||||
dow : 1, // Monday is the first day of the week.
|
||||
doy : 7 // The week that contains Jan 1st is the first week of the year.
|
||||
}
|
||||
});
|
||||
|
||||
//! moment.js locale configuration
|
||||
//! locale : Georgian (ka)
|
||||
//! author : Irakli Janiashvili : https://github.com/irakli-janiashvili
|
||||
|
@ -3820,25 +3892,42 @@
|
|||
//! moment.js locale configuration
|
||||
//! locale : latvian (lv)
|
||||
//! author : Kristaps Karlsons : https://github.com/skakri
|
||||
//! author : Jānis Elmeris : https://github.com/JanisE
|
||||
|
||||
var lv__units = {
|
||||
'mm': 'minūti_minūtes_minūte_minūtes',
|
||||
'hh': 'stundu_stundas_stunda_stundas',
|
||||
'dd': 'dienu_dienas_diena_dienas',
|
||||
'MM': 'mēnesi_mēnešus_mēnesis_mēneši',
|
||||
'yy': 'gadu_gadus_gads_gadi'
|
||||
'm': 'minūtes_minūtēm_minūte_minūtes'.split('_'),
|
||||
'mm': 'minūtes_minūtēm_minūte_minūtes'.split('_'),
|
||||
'h': 'stundas_stundām_stunda_stundas'.split('_'),
|
||||
'hh': 'stundas_stundām_stunda_stundas'.split('_'),
|
||||
'd': 'dienas_dienām_diena_dienas'.split('_'),
|
||||
'dd': 'dienas_dienām_diena_dienas'.split('_'),
|
||||
'M': 'mēneša_mēnešiem_mēnesis_mēneši'.split('_'),
|
||||
'MM': 'mēneša_mēnešiem_mēnesis_mēneši'.split('_'),
|
||||
'y': 'gada_gadiem_gads_gadi'.split('_'),
|
||||
'yy': 'gada_gadiem_gads_gadi'.split('_')
|
||||
};
|
||||
function format(word, number, withoutSuffix) {
|
||||
var forms = word.split('_');
|
||||
/**
|
||||
* @param withoutSuffix boolean true = a length of time; false = before/after a period of time.
|
||||
*/
|
||||
function format(forms, number, withoutSuffix) {
|
||||
if (withoutSuffix) {
|
||||
// E.g. "21 minūte", "3 minūtes".
|
||||
return number % 10 === 1 && number !== 11 ? forms[2] : forms[3];
|
||||
} else {
|
||||
// E.g. "21 minūtes" as in "pēc 21 minūtes".
|
||||
// E.g. "3 minūtēm" as in "pēc 3 minūtēm".
|
||||
return number % 10 === 1 && number !== 11 ? forms[0] : forms[1];
|
||||
}
|
||||
}
|
||||
function lv__relativeTimeWithPlural(number, withoutSuffix, key) {
|
||||
return number + ' ' + format(lv__units[key], number, withoutSuffix);
|
||||
}
|
||||
function relativeTimeWithSingular(number, withoutSuffix, key) {
|
||||
return format(lv__units[key], number, withoutSuffix);
|
||||
}
|
||||
function relativeSeconds(number, withoutSuffix) {
|
||||
return withoutSuffix ? 'dažas sekundes' : 'dažām sekundēm';
|
||||
}
|
||||
|
||||
var lv = moment.defineLocale('lv', {
|
||||
months : 'janvāris_februāris_marts_aprīlis_maijs_jūnijs_jūlijs_augusts_septembris_oktobris_novembris_decembris'.split('_'),
|
||||
|
@ -3849,7 +3938,7 @@
|
|||
longDateFormat : {
|
||||
LT : 'HH:mm',
|
||||
LTS : 'LT:ss',
|
||||
L : 'DD.MM.YYYY',
|
||||
L : 'DD.MM.YYYY.',
|
||||
LL : 'YYYY. [gada] D. MMMM',
|
||||
LLL : 'YYYY. [gada] D. MMMM, LT',
|
||||
LLLL : 'YYYY. [gada] D. MMMM, dddd, LT'
|
||||
|
@ -3863,18 +3952,18 @@
|
|||
sameElse : 'L'
|
||||
},
|
||||
relativeTime : {
|
||||
future : '%s vēlāk',
|
||||
past : '%s agrāk',
|
||||
s : 'dažas sekundes',
|
||||
m : 'minūti',
|
||||
future : 'pēc %s',
|
||||
past : 'pirms %s',
|
||||
s : relativeSeconds,
|
||||
m : relativeTimeWithSingular,
|
||||
mm : lv__relativeTimeWithPlural,
|
||||
h : 'stundu',
|
||||
h : relativeTimeWithSingular,
|
||||
hh : lv__relativeTimeWithPlural,
|
||||
d : 'dienu',
|
||||
d : relativeTimeWithSingular,
|
||||
dd : lv__relativeTimeWithPlural,
|
||||
M : 'mēnesi',
|
||||
M : relativeTimeWithSingular,
|
||||
MM : lv__relativeTimeWithPlural,
|
||||
y : 'gadu',
|
||||
y : relativeTimeWithSingular,
|
||||
yy : lv__relativeTimeWithPlural
|
||||
},
|
||||
ordinalParse: /\d{1,2}\./,
|
||||
|
@ -3885,6 +3974,104 @@
|
|||
}
|
||||
});
|
||||
|
||||
//! moment.js locale configuration
|
||||
//! locale : Montenegrin (me)
|
||||
//! author : Miodrag Nikač <miodrag@restartit.me> : https://github.com/miodragnikac
|
||||
|
||||
var me__translator = {
|
||||
words: { //Different grammatical cases
|
||||
m: ['jedan minut', 'jednog minuta'],
|
||||
mm: ['minut', 'minuta', 'minuta'],
|
||||
h: ['jedan sat', 'jednog sata'],
|
||||
hh: ['sat', 'sata', 'sati'],
|
||||
dd: ['dan', 'dana', 'dana'],
|
||||
MM: ['mjesec', 'mjeseca', 'mjeseci'],
|
||||
yy: ['godina', 'godine', 'godina']
|
||||
},
|
||||
correctGrammaticalCase: function (number, wordKey) {
|
||||
return number === 1 ? wordKey[0] : (number >= 2 && number <= 4 ? wordKey[1] : wordKey[2]);
|
||||
},
|
||||
translate: function (number, withoutSuffix, key) {
|
||||
var wordKey = me__translator.words[key];
|
||||
if (key.length === 1) {
|
||||
return withoutSuffix ? wordKey[0] : wordKey[1];
|
||||
} else {
|
||||
return number + ' ' + me__translator.correctGrammaticalCase(number, wordKey);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var me = moment.defineLocale('me', {
|
||||
months: ['januar', 'februar', 'mart', 'april', 'maj', 'jun', 'jul', 'avgust', 'septembar', 'oktobar', 'novembar', 'decembar'],
|
||||
monthsShort: ['jan.', 'feb.', 'mar.', 'apr.', 'maj', 'jun', 'jul', 'avg.', 'sep.', 'okt.', 'nov.', 'dec.'],
|
||||
weekdays: ['nedjelja', 'ponedjeljak', 'utorak', 'srijeda', 'četvrtak', 'petak', 'subota'],
|
||||
weekdaysShort: ['ned.', 'pon.', 'uto.', 'sri.', 'čet.', 'pet.', 'sub.'],
|
||||
weekdaysMin: ['ne', 'po', 'ut', 'sr', 'če', 'pe', 'su'],
|
||||
longDateFormat: {
|
||||
LT: 'H:mm',
|
||||
LTS : 'LT:ss',
|
||||
L: 'DD. MM. YYYY',
|
||||
LL: 'D. MMMM YYYY',
|
||||
LLL: 'D. MMMM YYYY LT',
|
||||
LLLL: 'dddd, D. MMMM YYYY LT'
|
||||
},
|
||||
calendar: {
|
||||
sameDay: '[danas u] LT',
|
||||
nextDay: '[sjutra u] LT',
|
||||
|
||||
nextWeek: function () {
|
||||
switch (this.day()) {
|
||||
case 0:
|
||||
return '[u] [nedjelju] [u] LT';
|
||||
case 3:
|
||||
return '[u] [srijedu] [u] LT';
|
||||
case 6:
|
||||
return '[u] [subotu] [u] LT';
|
||||
case 1:
|
||||
case 2:
|
||||
case 4:
|
||||
case 5:
|
||||
return '[u] dddd [u] LT';
|
||||
}
|
||||
},
|
||||
lastDay : '[juče u] LT',
|
||||
lastWeek : function () {
|
||||
var lastWeekDays = [
|
||||
'[prošle] [nedjelje] [u] LT',
|
||||
'[prošlog] [ponedjeljka] [u] LT',
|
||||
'[prošlog] [utorka] [u] LT',
|
||||
'[prošle] [srijede] [u] LT',
|
||||
'[prošlog] [četvrtka] [u] LT',
|
||||
'[prošlog] [petka] [u] LT',
|
||||
'[prošle] [subote] [u] LT'
|
||||
];
|
||||
return lastWeekDays[this.day()];
|
||||
},
|
||||
sameElse : 'L'
|
||||
},
|
||||
relativeTime : {
|
||||
future : 'za %s',
|
||||
past : 'prije %s',
|
||||
s : 'nekoliko sekundi',
|
||||
m : me__translator.translate,
|
||||
mm : me__translator.translate,
|
||||
h : me__translator.translate,
|
||||
hh : me__translator.translate,
|
||||
d : 'dan',
|
||||
dd : me__translator.translate,
|
||||
M : 'mjesec',
|
||||
MM : me__translator.translate,
|
||||
y : 'godinu',
|
||||
yy : me__translator.translate
|
||||
},
|
||||
ordinalParse: /\d{1,2}\./,
|
||||
ordinal : '%d.',
|
||||
week : {
|
||||
dow : 1, // Monday is the first day of the week.
|
||||
doy : 7 // The week that contains Jan 1st is the first week of the year.
|
||||
}
|
||||
});
|
||||
|
||||
//! moment.js locale configuration
|
||||
//! locale : macedonian (mk)
|
||||
//! author : Borislav Mickov : https://github.com/B0k0
|
||||
|
@ -4237,8 +4424,9 @@
|
|||
months: 'ဇန်နဝါရီ_ဖေဖော်ဝါရီ_မတ်_ဧပြီ_မေ_ဇွန်_ဇူလိုင်_သြဂုတ်_စက်တင်ဘာ_အောက်တိုဘာ_နိုဝင်ဘာ_ဒီဇင်ဘာ'.split('_'),
|
||||
monthsShort: 'ဇန်_ဖေ_မတ်_ပြီ_မေ_ဇွန်_လိုင်_သြ_စက်_အောက်_နို_ဒီ'.split('_'),
|
||||
weekdays: 'တနင်္ဂနွေ_တနင်္လာ_အင်္ဂါ_ဗုဒ္ဓဟူး_ကြာသပတေး_သောကြာ_စနေ'.split('_'),
|
||||
weekdaysShort: 'နွေ_လာ_င်္ဂါ_ဟူး_ကြာ_သော_နေ'.split('_'),
|
||||
weekdaysMin: 'နွေ_လာ_င်္ဂါ_ဟူး_ကြာ_သော_နေ'.split('_'),
|
||||
weekdaysShort: 'နွေ_လာ_ဂါ_ဟူး_ကြာ_သော_နေ'.split('_'),
|
||||
weekdaysMin: 'နွေ_လာ_ဂါ_ဟူး_ကြာ_သော_နေ'.split('_'),
|
||||
|
||||
longDateFormat: {
|
||||
LT: 'HH:mm',
|
||||
LTS: 'HH:mm:ss',
|
||||
|
@ -4586,7 +4774,12 @@
|
|||
|
||||
var pl = moment.defineLocale('pl', {
|
||||
months : function (momentToFormat, format) {
|
||||
if (/D MMMM/.test(format)) {
|
||||
if (format === '') {
|
||||
// Hack: if format empty we know this is used to generate
|
||||
// RegExp by moment. Give then back both valid forms of months
|
||||
// in RegExp ready format.
|
||||
return '(' + monthsSubjective[momentToFormat.month()] + '|' + monthsNominative[momentToFormat.month()] + ')';
|
||||
} else if (/D MMMM/.test(format)) {
|
||||
return monthsSubjective[momentToFormat.month()];
|
||||
} else {
|
||||
return monthsNominative[momentToFormat.month()];
|
||||
|
@ -4651,11 +4844,11 @@
|
|||
//! author : Caio Ribeiro Pereira : https://github.com/caio-ribeiro-pereira
|
||||
|
||||
var pt_br = moment.defineLocale('pt-br', {
|
||||
months : 'janeiro_fevereiro_março_abril_maio_junho_julho_agosto_setembro_outubro_novembro_dezembro'.split('_'),
|
||||
monthsShort : 'jan_fev_mar_abr_mai_jun_jul_ago_set_out_nov_dez'.split('_'),
|
||||
weekdays : 'domingo_segunda-feira_terça-feira_quarta-feira_quinta-feira_sexta-feira_sábado'.split('_'),
|
||||
weekdaysShort : 'dom_seg_ter_qua_qui_sex_sáb'.split('_'),
|
||||
weekdaysMin : 'dom_2ª_3ª_4ª_5ª_6ª_sáb'.split('_'),
|
||||
months : 'Janeiro_Fevereiro_Março_Abril_Maio_Junho_Julho_Agosto_Setembro_Outubro_Novembro_Dezembro'.split('_'),
|
||||
monthsShort : 'Jan_Fev_Mar_Abr_Mai_Jun_Jul_Ago_Set_Out_Nov_Dez'.split('_'),
|
||||
weekdays : 'Domingo_Segunda-Feira_Terça-Feira_Quarta-Feira_Quinta-Feira_Sexta-Feira_Sábado'.split('_'),
|
||||
weekdaysShort : 'Dom_Seg_Ter_Qua_Qui_Sex_Sáb'.split('_'),
|
||||
weekdaysMin : 'Dom_2ª_3ª_4ª_5ª_6ª_Sáb'.split('_'),
|
||||
longDateFormat : {
|
||||
LT : 'HH:mm',
|
||||
LTS : 'LT:ss',
|
||||
|
@ -4700,11 +4893,11 @@
|
|||
//! author : Jefferson : https://github.com/jalex79
|
||||
|
||||
var pt = moment.defineLocale('pt', {
|
||||
months : 'janeiro_fevereiro_março_abril_maio_junho_julho_agosto_setembro_outubro_novembro_dezembro'.split('_'),
|
||||
monthsShort : 'jan_fev_mar_abr_mai_jun_jul_ago_set_out_nov_dez'.split('_'),
|
||||
weekdays : 'domingo_segunda-feira_terça-feira_quarta-feira_quinta-feira_sexta-feira_sábado'.split('_'),
|
||||
weekdaysShort : 'dom_seg_ter_qua_qui_sex_sáb'.split('_'),
|
||||
weekdaysMin : 'dom_2ª_3ª_4ª_5ª_6ª_sáb'.split('_'),
|
||||
months : 'Janeiro_Fevereiro_Março_Abril_Maio_Junho_Julho_Agosto_Setembro_Outubro_Novembro_Dezembro'.split('_'),
|
||||
monthsShort : 'Jan_Fev_Mar_Abr_Mai_Jun_Jul_Ago_Set_Out_Nov_Dez'.split('_'),
|
||||
weekdays : 'Domingo_Segunda-Feira_Terça-Feira_Quarta-Feira_Quinta-Feira_Sexta-Feira_Sábado'.split('_'),
|
||||
weekdaysShort : 'Dom_Seg_Ter_Qua_Qui_Sex_Sáb'.split('_'),
|
||||
weekdaysMin : 'Dom_2ª_3ª_4ª_5ª_6ª_Sáb'.split('_'),
|
||||
longDateFormat : {
|
||||
LT : 'HH:mm',
|
||||
LTS : 'LT:ss',
|
||||
|
@ -4964,6 +5157,60 @@
|
|||
}
|
||||
});
|
||||
|
||||
//! moment.js locale configuration
|
||||
//! locale : Sinhalese (si)
|
||||
//! author : Sampath Sitinamaluwa : https://github.com/sampathsris
|
||||
|
||||
var si = moment.defineLocale('si', {
|
||||
months : 'ජනවාරි_පෙබරවාරි_මාර්තු_අප්රේල්_මැයි_ජූනි_ජූලි_අගෝස්තු_සැප්තැම්බර්_ඔක්තෝබර්_නොවැම්බර්_දෙසැම්බර්'.split('_'),
|
||||
monthsShort : 'ජන_පෙබ_මාර්_අප්_මැයි_ජූනි_ජූලි_අගෝ_සැප්_ඔක්_නොවැ_දෙසැ'.split('_'),
|
||||
weekdays : 'ඉරිදා_සඳුදා_අඟහරුවාදා_බදාදා_බ්රහස්පතින්දා_සිකුරාදා_සෙනසුරාදා'.split('_'),
|
||||
weekdaysShort : 'ඉරි_සඳු_අඟ_බදා_බ්රහ_සිකු_සෙන'.split('_'),
|
||||
weekdaysMin : 'ඉ_ස_අ_බ_බ්ර_සි_සෙ'.split('_'),
|
||||
longDateFormat : {
|
||||
LT : 'a h:mm',
|
||||
LTS : 'a h:mm:ss',
|
||||
L : 'YYYY/MM/DD',
|
||||
LL : 'YYYY MMMM D',
|
||||
LLL : 'YYYY MMMM D, LT',
|
||||
LLLL : 'YYYY MMMM D [වැනි] dddd, LTS'
|
||||
},
|
||||
calendar : {
|
||||
sameDay : '[අද] LT[ට]',
|
||||
nextDay : '[හෙට] LT[ට]',
|
||||
nextWeek : 'dddd LT[ට]',
|
||||
lastDay : '[ඊයේ] LT[ට]',
|
||||
lastWeek : '[පසුගිය] dddd LT[ට]',
|
||||
sameElse : 'L'
|
||||
},
|
||||
relativeTime : {
|
||||
future : '%sකින්',
|
||||
past : '%sකට පෙර',
|
||||
s : 'තත්පර කිහිපය',
|
||||
m : 'මිනිත්තුව',
|
||||
mm : 'මිනිත්තු %d',
|
||||
h : 'පැය',
|
||||
hh : 'පැය %d',
|
||||
d : 'දිනය',
|
||||
dd : 'දින %d',
|
||||
M : 'මාසය',
|
||||
MM : 'මාස %d',
|
||||
y : 'වසර',
|
||||
yy : 'වසර %d'
|
||||
},
|
||||
ordinalParse: /\d{1,2} වැනි/,
|
||||
ordinal : function (number) {
|
||||
return number + ' වැනි';
|
||||
},
|
||||
meridiem : function (hours, minutes, isLower) {
|
||||
if (hours > 11) {
|
||||
return isLower ? 'ප.ව.' : 'පස් වරු';
|
||||
} else {
|
||||
return isLower ? 'පෙ.ව.' : 'පෙර වරු';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//! moment.js locale configuration
|
||||
//! locale : slovak (sk)
|
||||
//! author : Martin Minka : https://github.com/k2s
|
||||
|
@ -5115,62 +5362,72 @@
|
|||
//! locale : slovenian (sl)
|
||||
//! author : Robert Sedovšek : https://github.com/sedovsek
|
||||
|
||||
function sl__translate(number, withoutSuffix, key) {
|
||||
function sl__processRelativeTime(number, withoutSuffix, key, isFuture) {
|
||||
var result = number + ' ';
|
||||
switch (key) {
|
||||
case 's':
|
||||
return withoutSuffix || isFuture ? 'nekaj sekund' : 'nekaj sekundami';
|
||||
case 'm':
|
||||
return withoutSuffix ? 'ena minuta' : 'eno minuto';
|
||||
case 'mm':
|
||||
if (number === 1) {
|
||||
result += 'minuta';
|
||||
result += withoutSuffix ? 'minuta' : 'minuto';
|
||||
} else if (number === 2) {
|
||||
result += 'minuti';
|
||||
} else if (number === 3 || number === 4) {
|
||||
result += 'minute';
|
||||
result += withoutSuffix || isFuture ? 'minuti' : 'minutama';
|
||||
} else if (number < 5) {
|
||||
result += withoutSuffix || isFuture ? 'minute' : 'minutami';
|
||||
} else {
|
||||
result += 'minut';
|
||||
result += withoutSuffix || isFuture ? 'minut' : 'minutami';
|
||||
}
|
||||
return result;
|
||||
case 'h':
|
||||
return withoutSuffix ? 'ena ura' : 'eno uro';
|
||||
case 'hh':
|
||||
if (number === 1) {
|
||||
result += 'ura';
|
||||
result += withoutSuffix ? 'ura' : 'uro';
|
||||
} else if (number === 2) {
|
||||
result += 'uri';
|
||||
} else if (number === 3 || number === 4) {
|
||||
result += 'ure';
|
||||
result += withoutSuffix || isFuture ? 'uri' : 'urama';
|
||||
} else if (number < 5) {
|
||||
result += withoutSuffix || isFuture ? 'ure' : 'urami';
|
||||
} else {
|
||||
result += 'ur';
|
||||
result += withoutSuffix || isFuture ? 'ur' : 'urami';
|
||||
}
|
||||
return result;
|
||||
case 'd':
|
||||
return withoutSuffix || isFuture ? 'en dan' : 'enim dnem';
|
||||
case 'dd':
|
||||
if (number === 1) {
|
||||
result += 'dan';
|
||||
result += withoutSuffix || isFuture ? 'dan' : 'dnem';
|
||||
} else if (number === 2) {
|
||||
result += withoutSuffix || isFuture ? 'dni' : 'dnevoma';
|
||||
} else {
|
||||
result += 'dni';
|
||||
result += withoutSuffix || isFuture ? 'dni' : 'dnevi';
|
||||
}
|
||||
return result;
|
||||
case 'M':
|
||||
return withoutSuffix || isFuture ? 'en mesec' : 'enim mesecem';
|
||||
case 'MM':
|
||||
if (number === 1) {
|
||||
result += 'mesec';
|
||||
result += withoutSuffix || isFuture ? 'mesec' : 'mesecem';
|
||||
} else if (number === 2) {
|
||||
result += 'meseca';
|
||||
} else if (number === 3 || number === 4) {
|
||||
result += 'mesece';
|
||||
result += withoutSuffix || isFuture ? 'meseca' : 'mesecema';
|
||||
} else if (number < 5) {
|
||||
result += withoutSuffix || isFuture ? 'mesece' : 'meseci';
|
||||
} else {
|
||||
result += 'mesecev';
|
||||
result += withoutSuffix || isFuture ? 'mesecev' : 'meseci';
|
||||
}
|
||||
return result;
|
||||
case 'y':
|
||||
return withoutSuffix || isFuture ? 'eno leto' : 'enim letom';
|
||||
case 'yy':
|
||||
if (number === 1) {
|
||||
result += 'leto';
|
||||
result += withoutSuffix || isFuture ? 'leto' : 'letom';
|
||||
} else if (number === 2) {
|
||||
result += 'leti';
|
||||
} else if (number === 3 || number === 4) {
|
||||
result += 'leta';
|
||||
result += withoutSuffix || isFuture ? 'leti' : 'letoma';
|
||||
} else if (number < 5) {
|
||||
result += withoutSuffix || isFuture ? 'leta' : 'leti';
|
||||
} else {
|
||||
result += 'let';
|
||||
result += withoutSuffix || isFuture ? 'let' : 'leti';
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -5193,6 +5450,7 @@
|
|||
calendar : {
|
||||
sameDay : '[danes ob] LT',
|
||||
nextDay : '[jutri ob] LT',
|
||||
|
||||
nextWeek : function () {
|
||||
switch (this.day()) {
|
||||
case 0:
|
||||
|
@ -5212,9 +5470,11 @@
|
|||
lastWeek : function () {
|
||||
switch (this.day()) {
|
||||
case 0:
|
||||
return '[prejšnjo] [nedeljo] [ob] LT';
|
||||
case 3:
|
||||
return '[prejšnjo] [sredo] [ob] LT';
|
||||
case 6:
|
||||
return '[prejšnja] dddd [ob] LT';
|
||||
return '[prejšnjo] [soboto] [ob] LT';
|
||||
case 1:
|
||||
case 2:
|
||||
case 4:
|
||||
|
@ -5226,18 +5486,18 @@
|
|||
},
|
||||
relativeTime : {
|
||||
future : 'čez %s',
|
||||
past : '%s nazaj',
|
||||
s : 'nekaj sekund',
|
||||
m : sl__translate,
|
||||
mm : sl__translate,
|
||||
h : sl__translate,
|
||||
hh : sl__translate,
|
||||
d : 'en dan',
|
||||
dd : sl__translate,
|
||||
M : 'en mesec',
|
||||
MM : sl__translate,
|
||||
y : 'eno leto',
|
||||
yy : sl__translate
|
||||
past : 'pred %s',
|
||||
s : sl__processRelativeTime,
|
||||
m : sl__processRelativeTime,
|
||||
mm : sl__processRelativeTime,
|
||||
h : sl__processRelativeTime,
|
||||
hh : sl__processRelativeTime,
|
||||
d : sl__processRelativeTime,
|
||||
dd : sl__processRelativeTime,
|
||||
M : sl__processRelativeTime,
|
||||
MM : sl__processRelativeTime,
|
||||
y : sl__processRelativeTime,
|
||||
yy : sl__processRelativeTime
|
||||
},
|
||||
ordinalParse: /\d{1,2}\./,
|
||||
ordinal : '%d.',
|
||||
|
@ -5521,8 +5781,8 @@
|
|||
sameDay: '[Idag] LT',
|
||||
nextDay: '[Imorgon] LT',
|
||||
lastDay: '[Igår] LT',
|
||||
nextWeek: 'dddd LT',
|
||||
lastWeek: '[Förra] dddd[en] LT',
|
||||
nextWeek: '[På] dddd LT',
|
||||
lastWeek: '[I] dddd[s] LT',
|
||||
sameElse: 'L'
|
||||
},
|
||||
relativeTime : {
|
||||
|
@ -6173,7 +6433,7 @@
|
|||
weekdaysShort : '周日_周一_周二_周三_周四_周五_周六'.split('_'),
|
||||
weekdaysMin : '日_一_二_三_四_五_六'.split('_'),
|
||||
longDateFormat : {
|
||||
LT : 'Ah点mm',
|
||||
LT : 'Ah点mm分',
|
||||
LTS : 'Ah点m分s秒',
|
||||
L : 'YYYY-MM-DD',
|
||||
LL : 'YYYY年MMMD日',
|
||||
|
@ -6259,16 +6519,16 @@
|
|||
future : '%s内',
|
||||
past : '%s前',
|
||||
s : '几秒',
|
||||
m : '1分钟',
|
||||
mm : '%d分钟',
|
||||
h : '1小时',
|
||||
hh : '%d小时',
|
||||
d : '1天',
|
||||
dd : '%d天',
|
||||
M : '1个月',
|
||||
MM : '%d个月',
|
||||
y : '1年',
|
||||
yy : '%d年'
|
||||
m : '1 分钟',
|
||||
mm : '%d 分钟',
|
||||
h : '1 小时',
|
||||
hh : '%d 小时',
|
||||
d : '1 天',
|
||||
dd : '%d 天',
|
||||
M : '1 个月',
|
||||
MM : '%d 个月',
|
||||
y : '1 年',
|
||||
yy : '%d 年'
|
||||
},
|
||||
week : {
|
||||
// GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
|
||||
|
@ -6288,7 +6548,7 @@
|
|||
weekdaysShort : '週日_週一_週二_週三_週四_週五_週六'.split('_'),
|
||||
weekdaysMin : '日_一_二_三_四_五_六'.split('_'),
|
||||
longDateFormat : {
|
||||
LT : 'Ah點mm',
|
||||
LT : 'Ah點mm分',
|
||||
LTS : 'Ah點m分s秒',
|
||||
L : 'YYYY年MMMD日',
|
||||
LL : 'YYYY年MMMD日',
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,5 @@
|
|||
//! moment.js
|
||||
//! version : 2.10.2
|
||||
//! version : 2.10.3
|
||||
//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
|
||||
//! license : MIT
|
||||
//! momentjs.com
|
||||
|
@ -22,28 +22,12 @@
|
|||
hookCallback = callback;
|
||||
}
|
||||
|
||||
function defaultParsingFlags() {
|
||||
// We need to deep clone this object.
|
||||
return {
|
||||
empty : false,
|
||||
unusedTokens : [],
|
||||
unusedInput : [],
|
||||
overflow : -2,
|
||||
charsLeftOver : 0,
|
||||
nullInput : false,
|
||||
invalidMonth : null,
|
||||
invalidFormat : false,
|
||||
userInvalidated : false,
|
||||
iso : false
|
||||
};
|
||||
}
|
||||
|
||||
function isArray(input) {
|
||||
return Object.prototype.toString.call(input) === '[object Array]';
|
||||
}
|
||||
|
||||
function isDate(input) {
|
||||
return Object.prototype.toString.call(input) === '[object Date]' || input instanceof Date;
|
||||
return input instanceof Date || Object.prototype.toString.call(input) === '[object Date]';
|
||||
}
|
||||
|
||||
function map(arr, fn) {
|
||||
|
@ -80,21 +64,45 @@
|
|||
return createLocalOrUTC(input, format, locale, strict, true).utc();
|
||||
}
|
||||
|
||||
function defaultParsingFlags() {
|
||||
// We need to deep clone this object.
|
||||
return {
|
||||
empty : false,
|
||||
unusedTokens : [],
|
||||
unusedInput : [],
|
||||
overflow : -2,
|
||||
charsLeftOver : 0,
|
||||
nullInput : false,
|
||||
invalidMonth : null,
|
||||
invalidFormat : false,
|
||||
userInvalidated : false,
|
||||
iso : false
|
||||
};
|
||||
}
|
||||
|
||||
function getParsingFlags(m) {
|
||||
if (m._pf == null) {
|
||||
m._pf = defaultParsingFlags();
|
||||
}
|
||||
return m._pf;
|
||||
}
|
||||
|
||||
function valid__isValid(m) {
|
||||
if (m._isValid == null) {
|
||||
var flags = getParsingFlags(m);
|
||||
m._isValid = !isNaN(m._d.getTime()) &&
|
||||
m._pf.overflow < 0 &&
|
||||
!m._pf.empty &&
|
||||
!m._pf.invalidMonth &&
|
||||
!m._pf.nullInput &&
|
||||
!m._pf.invalidFormat &&
|
||||
!m._pf.userInvalidated;
|
||||
flags.overflow < 0 &&
|
||||
!flags.empty &&
|
||||
!flags.invalidMonth &&
|
||||
!flags.nullInput &&
|
||||
!flags.invalidFormat &&
|
||||
!flags.userInvalidated;
|
||||
|
||||
if (m._strict) {
|
||||
m._isValid = m._isValid &&
|
||||
m._pf.charsLeftOver === 0 &&
|
||||
m._pf.unusedTokens.length === 0 &&
|
||||
m._pf.bigHour === undefined;
|
||||
flags.charsLeftOver === 0 &&
|
||||
flags.unusedTokens.length === 0 &&
|
||||
flags.bigHour === undefined;
|
||||
}
|
||||
}
|
||||
return m._isValid;
|
||||
|
@ -103,10 +111,10 @@
|
|||
function valid__createInvalid (flags) {
|
||||
var m = create_utc__createUTC(NaN);
|
||||
if (flags != null) {
|
||||
extend(m._pf, flags);
|
||||
extend(getParsingFlags(m), flags);
|
||||
}
|
||||
else {
|
||||
m._pf.userInvalidated = true;
|
||||
getParsingFlags(m).userInvalidated = true;
|
||||
}
|
||||
|
||||
return m;
|
||||
|
@ -142,7 +150,7 @@
|
|||
to._offset = from._offset;
|
||||
}
|
||||
if (typeof from._pf !== 'undefined') {
|
||||
to._pf = from._pf;
|
||||
to._pf = getParsingFlags(from);
|
||||
}
|
||||
if (typeof from._locale !== 'undefined') {
|
||||
to._locale = from._locale;
|
||||
|
@ -177,7 +185,7 @@
|
|||
}
|
||||
|
||||
function isMoment (obj) {
|
||||
return obj instanceof Moment || (obj != null && hasOwnProp(obj, '_isAMomentObject'));
|
||||
return obj instanceof Moment || (obj != null && obj._isAMomentObject != null);
|
||||
}
|
||||
|
||||
function toInt(argumentForCoercion) {
|
||||
|
@ -615,7 +623,7 @@
|
|||
if (month != null) {
|
||||
array[MONTH] = month;
|
||||
} else {
|
||||
config._pf.invalidMonth = input;
|
||||
getParsingFlags(config).invalidMonth = input;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -699,7 +707,7 @@
|
|||
var overflow;
|
||||
var a = m._a;
|
||||
|
||||
if (a && m._pf.overflow === -2) {
|
||||
if (a && getParsingFlags(m).overflow === -2) {
|
||||
overflow =
|
||||
a[MONTH] < 0 || a[MONTH] > 11 ? MONTH :
|
||||
a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH]) ? DATE :
|
||||
|
@ -709,11 +717,11 @@
|
|||
a[MILLISECOND] < 0 || a[MILLISECOND] > 999 ? MILLISECOND :
|
||||
-1;
|
||||
|
||||
if (m._pf._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) {
|
||||
if (getParsingFlags(m)._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) {
|
||||
overflow = DATE;
|
||||
}
|
||||
|
||||
m._pf.overflow = overflow;
|
||||
getParsingFlags(m).overflow = overflow;
|
||||
}
|
||||
|
||||
return m;
|
||||
|
@ -726,10 +734,12 @@
|
|||
}
|
||||
|
||||
function deprecate(msg, fn) {
|
||||
var firstTime = true;
|
||||
var firstTime = true,
|
||||
msgWithStack = msg + '\n' + (new Error()).stack;
|
||||
|
||||
return extend(function () {
|
||||
if (firstTime) {
|
||||
warn(msg);
|
||||
warn(msgWithStack);
|
||||
firstTime = false;
|
||||
}
|
||||
return fn.apply(this, arguments);
|
||||
|
@ -774,7 +784,7 @@
|
|||
match = from_string__isoRegex.exec(string);
|
||||
|
||||
if (match) {
|
||||
config._pf.iso = true;
|
||||
getParsingFlags(config).iso = true;
|
||||
for (i = 0, l = isoDates.length; i < l; i++) {
|
||||
if (isoDates[i][1].exec(string)) {
|
||||
// match[5] should be 'T' or undefined
|
||||
|
@ -1054,7 +1064,7 @@
|
|||
yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
|
||||
|
||||
if (config._dayOfYear > daysInYear(yearToUse)) {
|
||||
config._pf._overflowDayOfYear = true;
|
||||
getParsingFlags(config)._overflowDayOfYear = true;
|
||||
}
|
||||
|
||||
date = createUTCDate(yearToUse, 0, config._dayOfYear);
|
||||
|
@ -1150,7 +1160,7 @@
|
|||
}
|
||||
|
||||
config._a = [];
|
||||
config._pf.empty = true;
|
||||
getParsingFlags(config).empty = true;
|
||||
|
||||
// This array is used to make a Date, either with `new Date` or `Date.UTC`
|
||||
var string = '' + config._i,
|
||||
|
@ -1166,7 +1176,7 @@
|
|||
if (parsedInput) {
|
||||
skipped = string.substr(0, string.indexOf(parsedInput));
|
||||
if (skipped.length > 0) {
|
||||
config._pf.unusedInput.push(skipped);
|
||||
getParsingFlags(config).unusedInput.push(skipped);
|
||||
}
|
||||
string = string.slice(string.indexOf(parsedInput) + parsedInput.length);
|
||||
totalParsedInputLength += parsedInput.length;
|
||||
|
@ -1174,27 +1184,29 @@
|
|||
// don't parse if it's not a known token
|
||||
if (formatTokenFunctions[token]) {
|
||||
if (parsedInput) {
|
||||
config._pf.empty = false;
|
||||
getParsingFlags(config).empty = false;
|
||||
}
|
||||
else {
|
||||
config._pf.unusedTokens.push(token);
|
||||
getParsingFlags(config).unusedTokens.push(token);
|
||||
}
|
||||
addTimeToArrayFromToken(token, parsedInput, config);
|
||||
}
|
||||
else if (config._strict && !parsedInput) {
|
||||
config._pf.unusedTokens.push(token);
|
||||
getParsingFlags(config).unusedTokens.push(token);
|
||||
}
|
||||
}
|
||||
|
||||
// add remaining unparsed input length to the string
|
||||
config._pf.charsLeftOver = stringLength - totalParsedInputLength;
|
||||
getParsingFlags(config).charsLeftOver = stringLength - totalParsedInputLength;
|
||||
if (string.length > 0) {
|
||||
config._pf.unusedInput.push(string);
|
||||
getParsingFlags(config).unusedInput.push(string);
|
||||
}
|
||||
|
||||
// clear _12h flag if hour is <= 12
|
||||
if (config._pf.bigHour === true && config._a[HOUR] <= 12) {
|
||||
config._pf.bigHour = undefined;
|
||||
if (getParsingFlags(config).bigHour === true &&
|
||||
config._a[HOUR] <= 12 &&
|
||||
config._a[HOUR] > 0) {
|
||||
getParsingFlags(config).bigHour = undefined;
|
||||
}
|
||||
// handle meridiem
|
||||
config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem);
|
||||
|
@ -1238,7 +1250,7 @@
|
|||
currentScore;
|
||||
|
||||
if (config._f.length === 0) {
|
||||
config._pf.invalidFormat = true;
|
||||
getParsingFlags(config).invalidFormat = true;
|
||||
config._d = new Date(NaN);
|
||||
return;
|
||||
}
|
||||
|
@ -1249,7 +1261,6 @@
|
|||
if (config._useUTC != null) {
|
||||
tempConfig._useUTC = config._useUTC;
|
||||
}
|
||||
tempConfig._pf = defaultParsingFlags();
|
||||
tempConfig._f = config._f[i];
|
||||
configFromStringAndFormat(tempConfig);
|
||||
|
||||
|
@ -1258,12 +1269,12 @@
|
|||
}
|
||||
|
||||
// if there is any input that was not parsed add a penalty for that format
|
||||
currentScore += tempConfig._pf.charsLeftOver;
|
||||
currentScore += getParsingFlags(tempConfig).charsLeftOver;
|
||||
|
||||
//or tokens
|
||||
currentScore += tempConfig._pf.unusedTokens.length * 10;
|
||||
currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;
|
||||
|
||||
tempConfig._pf.score = currentScore;
|
||||
getParsingFlags(tempConfig).score = currentScore;
|
||||
|
||||
if (scoreToBeat == null || currentScore < scoreToBeat) {
|
||||
scoreToBeat = currentScore;
|
||||
|
@ -1306,6 +1317,8 @@
|
|||
configFromStringAndArray(config);
|
||||
} else if (format) {
|
||||
configFromStringAndFormat(config);
|
||||
} else if (isDate(input)) {
|
||||
config._d = input;
|
||||
} else {
|
||||
configFromInput(config);
|
||||
}
|
||||
|
@ -1358,7 +1371,6 @@
|
|||
c._i = input;
|
||||
c._f = format;
|
||||
c._strict = strict;
|
||||
c._pf = defaultParsingFlags();
|
||||
|
||||
return createFromConfig(c);
|
||||
}
|
||||
|
@ -1932,6 +1944,9 @@
|
|||
}
|
||||
|
||||
function from (time, withoutSuffix) {
|
||||
if (!this.isValid()) {
|
||||
return this.localeData().invalidDate();
|
||||
}
|
||||
return create__createDuration({to: this, from: time}).locale(this.locale()).humanize(!withoutSuffix);
|
||||
}
|
||||
|
||||
|
@ -1939,6 +1954,17 @@
|
|||
return this.from(local__createLocal(), withoutSuffix);
|
||||
}
|
||||
|
||||
function to (time, withoutSuffix) {
|
||||
if (!this.isValid()) {
|
||||
return this.localeData().invalidDate();
|
||||
}
|
||||
return create__createDuration({from: this, to: time}).locale(this.locale()).humanize(!withoutSuffix);
|
||||
}
|
||||
|
||||
function toNow (withoutSuffix) {
|
||||
return this.to(local__createLocal(), withoutSuffix);
|
||||
}
|
||||
|
||||
function locale (key) {
|
||||
var newLocaleData;
|
||||
|
||||
|
@ -2041,11 +2067,11 @@
|
|||
}
|
||||
|
||||
function parsingFlags () {
|
||||
return extend({}, this._pf);
|
||||
return extend({}, getParsingFlags(this));
|
||||
}
|
||||
|
||||
function invalidAt () {
|
||||
return this._pf.overflow;
|
||||
return getParsingFlags(this).overflow;
|
||||
}
|
||||
|
||||
addFormatToken(0, ['gg', 2], 0, function () {
|
||||
|
@ -2196,7 +2222,7 @@
|
|||
if (weekday != null) {
|
||||
week.d = weekday;
|
||||
} else {
|
||||
config._pf.invalidWeekday = input;
|
||||
getParsingFlags(config).invalidWeekday = input;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -2321,7 +2347,7 @@
|
|||
});
|
||||
addParseToken(['h', 'hh'], function (input, array, config) {
|
||||
array[HOUR] = toInt(input);
|
||||
config._pf.bigHour = true;
|
||||
getParsingFlags(config).bigHour = true;
|
||||
});
|
||||
|
||||
// LOCALES
|
||||
|
@ -2438,6 +2464,8 @@
|
|||
momentPrototype__proto.format = format;
|
||||
momentPrototype__proto.from = from;
|
||||
momentPrototype__proto.fromNow = fromNow;
|
||||
momentPrototype__proto.to = to;
|
||||
momentPrototype__proto.toNow = toNow;
|
||||
momentPrototype__proto.get = getSet;
|
||||
momentPrototype__proto.invalidAt = invalidAt;
|
||||
momentPrototype__proto.isAfter = isAfter;
|
||||
|
@ -2626,7 +2654,7 @@
|
|||
}
|
||||
// Lenient ordinal parsing accepts just a number in addition to
|
||||
// number + (possibly) stuff coming from _ordinalParseLenient.
|
||||
this._ordinalParseLenient = new RegExp(this._ordinalParse.source + '|' + /\d{1,2}/.source);
|
||||
this._ordinalParseLenient = new RegExp(this._ordinalParse.source + '|' + (/\d{1,2}/).source);
|
||||
}
|
||||
|
||||
var prototype__proto = Locale.prototype;
|
||||
|
@ -2843,13 +2871,13 @@
|
|||
// handle milliseconds separately because of floating point math errors (issue #1867)
|
||||
days = this._days + Math.round(yearsToDays(this._months / 12));
|
||||
switch (units) {
|
||||
case 'week' : return days / 7 + milliseconds / 6048e5;
|
||||
case 'day' : return days + milliseconds / 864e5;
|
||||
case 'hour' : return days * 24 + milliseconds / 36e5;
|
||||
case 'minute' : return days * 24 * 60 + milliseconds / 6e4;
|
||||
case 'second' : return days * 24 * 60 * 60 + milliseconds / 1000;
|
||||
case 'week' : return days / 7 + milliseconds / 6048e5;
|
||||
case 'day' : return days + milliseconds / 864e5;
|
||||
case 'hour' : return days * 24 + milliseconds / 36e5;
|
||||
case 'minute' : return days * 1440 + milliseconds / 6e4;
|
||||
case 'second' : return days * 86400 + milliseconds / 1000;
|
||||
// Math.floor prevents floating point math errors here
|
||||
case 'millisecond': return Math.floor(days * 24 * 60 * 60 * 1000) + milliseconds;
|
||||
case 'millisecond': return Math.floor(days * 864e5) + milliseconds;
|
||||
default: throw new Error('Unknown unit ' + units);
|
||||
}
|
||||
}
|
||||
|
@ -3050,7 +3078,7 @@
|
|||
// Side effect imports
|
||||
|
||||
|
||||
utils_hooks__hooks.version = '2.10.2';
|
||||
utils_hooks__hooks.version = '2.10.3';
|
||||
|
||||
setHookCallback(local__createLocal);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "moment",
|
||||
"version": "2.10.2",
|
||||
"version": "2.10.3",
|
||||
"description": "Parse, validate, manipulate, and display dates",
|
||||
"homepage": "http://momentjs.com",
|
||||
"author": {
|
||||
|
@ -113,10 +113,10 @@
|
|||
"locale/*.js"
|
||||
]
|
||||
},
|
||||
"_id": "moment@2.10.2",
|
||||
"_id": "moment@2.10.3",
|
||||
"dist": {
|
||||
"shasum": "faf8c09ca82f03f94962e3b5a7239263ea50d087",
|
||||
"tarball": "http://registry.npmjs.org/moment/-/moment-2.10.2.tgz"
|
||||
"shasum": "0abb99f307f65218308c6935efe29c57b1a0a27f",
|
||||
"tarball": "http://registry.npmjs.org/moment/-/moment-2.10.3.tgz"
|
||||
},
|
||||
"_from": "moment@>=2.0.0 <3.0.0",
|
||||
"_npmVersion": "1.4.6",
|
||||
|
@ -135,7 +135,6 @@
|
|||
}
|
||||
],
|
||||
"directories": {},
|
||||
"_shasum": "faf8c09ca82f03f94962e3b5a7239263ea50d087",
|
||||
"_resolved": "https://registry.npmjs.org/moment/-/moment-2.10.2.tgz",
|
||||
"readme": "ERROR: No README data found!"
|
||||
"_shasum": "0abb99f307f65218308c6935efe29c57b1a0a27f",
|
||||
"_resolved": "https://registry.npmjs.org/moment/-/moment-2.10.3.tgz"
|
||||
}
|
||||
|
|
2
js/node/node_modules/joi/node_modules/topo/package.json
generated
vendored
Executable file → Normal file
2
js/node/node_modules/joi/node_modules/topo/package.json
generated
vendored
Executable file → Normal file
|
@ -4,7 +4,7 @@
|
|||
"version": "1.0.2",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/hapijs/topo"
|
||||
"url": "git://github.com/hapijs/topo.git"
|
||||
},
|
||||
"main": "index",
|
||||
"keywords": [
|
||||
|
|
|
@ -1,18 +1,19 @@
|
|||
{
|
||||
"name": "joi",
|
||||
"description": "Object schema validation",
|
||||
"version": "6.1.0",
|
||||
"version": "6.4.3",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/hapijs/joi"
|
||||
"url": "git://github.com/hapijs/joi.git"
|
||||
},
|
||||
"main": "index",
|
||||
"main": "lib/index.js",
|
||||
"keywords": [
|
||||
"schema",
|
||||
"validation"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=0.10.30"
|
||||
"node": ">=0.10.30",
|
||||
"npm": "2.x"
|
||||
},
|
||||
"dependencies": {
|
||||
"hoek": "^2.2.x",
|
||||
|
@ -30,25 +31,25 @@
|
|||
"test-cov-html": "lab -r html -o coverage.html -a code",
|
||||
"toc": "node generate-readme-toc.js"
|
||||
},
|
||||
"licenses": [
|
||||
{
|
||||
"type": "BSD",
|
||||
"url": "http://github.com/hapijs/joi/raw/master/LICENSE"
|
||||
}
|
||||
],
|
||||
"gitHead": "a395450ab6adb85c68cf0dd38e8e000a4694e990",
|
||||
"license": "BSD-3-Clause",
|
||||
"gitHead": "de65dc5ab5054976b9bb6a728563f39cb310780b",
|
||||
"bugs": {
|
||||
"url": "https://github.com/hapijs/joi/issues"
|
||||
},
|
||||
"homepage": "https://github.com/hapijs/joi",
|
||||
"_id": "joi@6.1.0",
|
||||
"_shasum": "4141230a69866d12059c0a3ebe85b09ff8246779",
|
||||
"_from": "joi@6.1.0",
|
||||
"_npmVersion": "1.4.28",
|
||||
"homepage": "https://github.com/hapijs/joi#readme",
|
||||
"_id": "joi@6.4.3",
|
||||
"_shasum": "340176729c65cf11ef063306be7e726a8e38c665",
|
||||
"_from": "joi@6.4.3",
|
||||
"_npmVersion": "2.8.4",
|
||||
"_nodeVersion": "0.10.30",
|
||||
"_npmUser": {
|
||||
"name": "marsup",
|
||||
"email": "marsup@gmail.com"
|
||||
},
|
||||
"dist": {
|
||||
"shasum": "340176729c65cf11ef063306be7e726a8e38c665",
|
||||
"tarball": "http://registry.npmjs.org/joi/-/joi-6.4.3.tgz"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "hueniverse",
|
||||
|
@ -59,10 +60,6 @@
|
|||
"email": "marsup@gmail.com"
|
||||
}
|
||||
],
|
||||
"dist": {
|
||||
"shasum": "4141230a69866d12059c0a3ebe85b09ff8246779",
|
||||
"tarball": "http://registry.npmjs.org/joi/-/joi-6.1.0.tgz"
|
||||
},
|
||||
"directories": {},
|
||||
"_resolved": "https://registry.npmjs.org/joi/-/joi-6.1.0.tgz"
|
||||
"_resolved": "https://registry.npmjs.org/joi/-/joi-6.4.3.tgz"
|
||||
}
|
||||
|
|
|
@ -189,6 +189,22 @@ describe('alternatives', function () {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('validates when is is null', function (done) {
|
||||
|
||||
var schema = {
|
||||
a: Joi.alternatives().when('b', { is: null, then: 'x', otherwise: Joi.number() }),
|
||||
b: Joi.any()
|
||||
};
|
||||
|
||||
Helper.validate(schema, [
|
||||
[{ a: 1 }, true],
|
||||
[{ a: 'y' }, false],
|
||||
[{ a: 'x', b: null }, true],
|
||||
[{ a: 'y', b: null }, false],
|
||||
[{ a: 1, b: null }, false]
|
||||
], done);
|
||||
});
|
||||
|
||||
it('validates when is has ref', function (done) {
|
||||
|
||||
var schema = {
|
||||
|
@ -291,7 +307,8 @@ describe('alternatives', function () {
|
|||
is: {
|
||||
type: 'number',
|
||||
flags: {
|
||||
allowOnly: true
|
||||
allowOnly: true,
|
||||
presence: 'required'
|
||||
},
|
||||
valids: [5],
|
||||
invalids: [Infinity, -Infinity]
|
||||
|
@ -352,7 +369,8 @@ describe('alternatives', function () {
|
|||
is: {
|
||||
type: 'number',
|
||||
flags: {
|
||||
allowOnly: true
|
||||
allowOnly: true,
|
||||
presence: 'required'
|
||||
},
|
||||
valids: [5],
|
||||
invalids: [Infinity, -Infinity]
|
||||
|
@ -405,7 +423,8 @@ describe('alternatives', function () {
|
|||
is: {
|
||||
type: 'number',
|
||||
flags: {
|
||||
allowOnly: true
|
||||
allowOnly: true,
|
||||
presence: 'required'
|
||||
},
|
||||
valids: [5],
|
||||
invalids: [Infinity, -Infinity]
|
||||
|
|
|
@ -245,7 +245,13 @@ describe('any', function () {
|
|||
|
||||
expect(function () {
|
||||
|
||||
var schema = Joi.object({ foo: Joi.string().default(function () { return 'test'; }) });
|
||||
var schema = Joi.object({
|
||||
foo: Joi.string().default(function () {
|
||||
|
||||
return 'test';
|
||||
|
||||
})
|
||||
});
|
||||
}).to.throw();
|
||||
|
||||
done();
|
||||
|
@ -269,7 +275,12 @@ describe('any', function () {
|
|||
|
||||
it('sets the value when passing a method', function (done) {
|
||||
|
||||
var schema = Joi.object({ foo: Joi.string().default(function () { return 'test'; }, 'testing') });
|
||||
var schema = Joi.object({
|
||||
foo: Joi.string().default(function () {
|
||||
|
||||
return 'test';
|
||||
}, 'testing')
|
||||
});
|
||||
var input = {};
|
||||
|
||||
schema.validate(input, function (err, value) {
|
||||
|
@ -283,7 +294,12 @@ describe('any', function () {
|
|||
it('executes the default method each time validate is called', function (done) {
|
||||
|
||||
var count = 0;
|
||||
var schema = Joi.object({ foo: Joi.number().default(function () { return ++count; }, 'incrementer') });
|
||||
var schema = Joi.object({
|
||||
foo: Joi.number().default(function () {
|
||||
|
||||
return ++count;
|
||||
}, 'incrementer')
|
||||
});
|
||||
var input = {};
|
||||
|
||||
schema.validate(input, function (err, value) {
|
||||
|
@ -304,7 +320,10 @@ describe('any', function () {
|
|||
it('passes a clone of the context if the default method accepts an argument', function (done) {
|
||||
|
||||
var schema = Joi.object({
|
||||
foo: Joi.string().default(function (context) { return context.bar + 'ing'; }, 'testing'),
|
||||
foo: Joi.string().default(function (context) {
|
||||
|
||||
return context.bar + 'ing';
|
||||
}, 'testing'),
|
||||
bar: Joi.string()
|
||||
});
|
||||
var input = { bar: 'test' };
|
||||
|
@ -506,6 +525,34 @@ describe('any', function () {
|
|||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('creates deep defaults', function (done) {
|
||||
|
||||
var schema = Joi.object({
|
||||
a: Joi.number().default(42),
|
||||
b: Joi.object({
|
||||
c: Joi.boolean().default(true),
|
||||
d: Joi.string()
|
||||
}).default()
|
||||
}).default();
|
||||
|
||||
Helper.validate(schema, [
|
||||
[undefined, true, null, { a: 42, b: { c: true }}],
|
||||
[{ a: 24 }, true, null, { a: 24, b: { c: true }}]
|
||||
], done);
|
||||
});
|
||||
|
||||
it('should not affect objects other than object when called without an argument', function (done) {
|
||||
|
||||
var schema = Joi.object({
|
||||
a: Joi.number().default()
|
||||
}).default();
|
||||
|
||||
Helper.validate(schema, [
|
||||
[undefined, true, null, {}],
|
||||
[{ a: 24 }, true, null, { a: 24 }]
|
||||
], done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#optional', function () {
|
||||
|
@ -750,7 +797,7 @@ describe('any', function () {
|
|||
expect(function () {
|
||||
|
||||
Joi.string().concat(Joi.number());
|
||||
}).to.throw('Cannot merge with another type: number');
|
||||
}).to.throw('Cannot merge type string with another type: number');
|
||||
done();
|
||||
});
|
||||
|
||||
|
@ -1018,7 +1065,7 @@ describe('any', function () {
|
|||
expect(function () {
|
||||
|
||||
a.concat(b);
|
||||
}).to.throw('Cannot merge with another type: string');
|
||||
}).to.throw('Cannot merge type number with another type: string');
|
||||
done();
|
||||
});
|
||||
|
||||
|
@ -1054,6 +1101,23 @@ describe('any', function () {
|
|||
|
||||
done();
|
||||
});
|
||||
|
||||
it('merges into an any', function (done) {
|
||||
|
||||
var a = Joi.any().required();
|
||||
var b = Joi.number().only(0);
|
||||
|
||||
expect(function () {
|
||||
|
||||
a.concat(b);
|
||||
}).to.not.throw();
|
||||
|
||||
var schema = a.concat(b);
|
||||
expect(schema.validate().error.message).to.equal('"value" is required');
|
||||
expect(schema.validate(1).error.message).to.equal('"value" must be one of [0]');
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('#when', function () {
|
||||
|
@ -1124,6 +1188,25 @@ describe('any', function () {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('forks type into alternatives (with a schema)', function (done) {
|
||||
|
||||
var schema = {
|
||||
a: Joi.any(),
|
||||
b: Joi.string().valid('x').when('a', { is: Joi.number().only(5).required(), then: Joi.valid('y') })
|
||||
};
|
||||
|
||||
Helper.validate(schema, [
|
||||
[{ a: 5, b: 'x' }, true],
|
||||
[{ a: 5, b: 'y' }, true],
|
||||
[{ a: 5, b: 'z' }, false],
|
||||
[{ a: 1, b: 'x' }, true],
|
||||
[{ a: 1, b: 'y' }, false],
|
||||
[{ a: 1, b: 'z' }, false],
|
||||
[{ a: 5, b: 'a' }, false],
|
||||
[{ b: 'a' }, false]
|
||||
], done);
|
||||
});
|
||||
|
||||
it('makes peer required', function (done) {
|
||||
|
||||
var schema = {
|
||||
|
@ -1184,18 +1267,23 @@ describe('any', function () {
|
|||
|
||||
it('should throw on unknown key', function (done) {
|
||||
|
||||
expect(function() {
|
||||
expect(function () {
|
||||
|
||||
Joi.object({ a: 0, b: 0 }).requiredKeys('a', 'c', 'b', 'd', 'd.e.f');
|
||||
}).to.throw(Error, 'unknown key(s) c, d');
|
||||
expect(function() {
|
||||
|
||||
expect(function () {
|
||||
|
||||
Joi.object({ a: 0, b: 0 }).requiredKeys('a', 'b', 'a.c.d');
|
||||
}).to.throw(Error, 'unknown key(s) a.c.d');
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should throw on empty object', function (done) {
|
||||
|
||||
expect(function() {
|
||||
expect(function () {
|
||||
|
||||
Joi.object().requiredKeys('a', 'c', 'b', 'd');
|
||||
}).to.throw(Error, 'unknown key(s) a, b, c, d');
|
||||
done();
|
||||
|
@ -1231,6 +1319,65 @@ describe('any', function () {
|
|||
});
|
||||
});
|
||||
|
||||
describe('#empty', function () {
|
||||
|
||||
it('should void values when considered empty', function (done) {
|
||||
|
||||
var schema = Joi.string().empty('');
|
||||
Helper.validate(schema, [
|
||||
[undefined, true, null, undefined],
|
||||
['abc', true, null, 'abc'],
|
||||
['', true, null, undefined]
|
||||
], done);
|
||||
});
|
||||
|
||||
it('should override any previous empty', function (done) {
|
||||
|
||||
var schema = Joi.string().empty('').empty('abc');
|
||||
Helper.validate(schema, [
|
||||
[undefined, true, null, undefined],
|
||||
['abc', true, null, undefined],
|
||||
['', false, null, '"value" is not allowed to be empty'],
|
||||
['def', true, null, 'def']
|
||||
], done);
|
||||
});
|
||||
|
||||
it('should be possible to reset the empty value', function (done) {
|
||||
|
||||
var schema = Joi.string().empty('').empty();
|
||||
Helper.validate(schema, [
|
||||
[undefined, true, null, undefined],
|
||||
['abc', true, null, 'abc'],
|
||||
['', false, null, '"value" is not allowed to be empty']
|
||||
], done);
|
||||
});
|
||||
|
||||
it('should have no effect if only reset is used', function (done) {
|
||||
|
||||
var schema = Joi.string().empty();
|
||||
Helper.validate(schema, [
|
||||
[undefined, true, null, undefined],
|
||||
['abc', true, null, 'abc'],
|
||||
['', false, null, '"value" is not allowed to be empty']
|
||||
], done);
|
||||
});
|
||||
|
||||
it('should work with dependencies', function (done) {
|
||||
|
||||
var schema = Joi.object({
|
||||
a: Joi.string().empty(''),
|
||||
b: Joi.string().empty('')
|
||||
}).or('a', 'b');
|
||||
|
||||
Helper.validate(schema, [
|
||||
[{}, false, null, '"value" must contain at least one of [a, b]'],
|
||||
[{ a: '' }, false, null, '"value" must contain at least one of [a, b]'],
|
||||
[{ a: 'a' }, true, null, { a: 'a' }],
|
||||
[{ a: '', b: 'b' }, true, null, { b: 'b' }]
|
||||
], done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Set', function () {
|
||||
|
||||
describe('#add', function () {
|
||||
|
|
|
@ -133,6 +133,16 @@ describe('array', function () {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('validates multiple types with stripUnknown', function (done) {
|
||||
|
||||
var schema = Joi.array().items(Joi.number(), Joi.string()).options({ stripUnknown: true });
|
||||
|
||||
Helper.validate(schema, [
|
||||
[[1, 2, 'a'], true, null, [1, 2, 'a']],
|
||||
[[1, { foo: 'bar'}, 'a', 2], true, null, [1, 'a', 2]]
|
||||
], done);
|
||||
});
|
||||
|
||||
it('allows forbidden to restrict values', function (done) {
|
||||
|
||||
var schema = Joi.array().items(Joi.string().valid('four').forbidden(), Joi.string());
|
||||
|
@ -584,17 +594,18 @@ describe('array', function () {
|
|||
});
|
||||
});
|
||||
|
||||
describe('#unique', function() {
|
||||
describe('#unique', function () {
|
||||
|
||||
it('errors if duplicate numbers, strings, objects, binaries, functions, dates and booleans', function (done) {
|
||||
|
||||
it('errors if duplicate numbers, strings, objects, binaries, functions, dates and booleans', function(done) {
|
||||
var buffer = new Buffer('hello world');
|
||||
var func = function() {};
|
||||
var func = function () {};
|
||||
var now = new Date();
|
||||
var schema = Joi.array().sparse().unique();
|
||||
|
||||
Helper.validate(schema, [
|
||||
[[2, 2], false],
|
||||
[[02, 2], false],
|
||||
[[02, 2], false], // eslint-disable-line no-octal
|
||||
[[0x2, 2], false],
|
||||
[['duplicate', 'duplicate'], false],
|
||||
[[{ a: 'b' }, { a: 'b' }], false],
|
||||
|
@ -606,7 +617,8 @@ describe('array', function () {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('ignores duplicates if they are of different types', function(done) {
|
||||
it('ignores duplicates if they are of different types', function (done) {
|
||||
|
||||
var schema = Joi.array().unique();
|
||||
|
||||
Helper.validate(schema, [
|
||||
|
@ -614,11 +626,12 @@ describe('array', function () {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('validates without duplicates', function(done) {
|
||||
it('validates without duplicates', function (done) {
|
||||
|
||||
var buffer = new Buffer('hello world');
|
||||
var buffer2 = new Buffer('Hello world');
|
||||
var func = function() {};
|
||||
var func2 = function() {};
|
||||
var func = function () {};
|
||||
var func2 = function () {};
|
||||
var now = new Date();
|
||||
var now2 = new Date(+now + 100);
|
||||
var schema = Joi.array().unique();
|
||||
|
@ -691,9 +704,9 @@ describe('array', function () {
|
|||
});
|
||||
});
|
||||
|
||||
describe('#single', function() {
|
||||
describe('#single', function () {
|
||||
|
||||
it('should allow a single element', function(done) {
|
||||
it('should allow a single element', function (done) {
|
||||
|
||||
var schema = Joi.array().items(Joi.number()).items(Joi.boolean().forbidden()).single();
|
||||
|
||||
|
@ -706,7 +719,7 @@ describe('array', function () {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('should allow a single element with multiple types', function(done) {
|
||||
it('should allow a single element with multiple types', function (done) {
|
||||
|
||||
var schema = Joi.array().items(Joi.number(), Joi.string()).single();
|
||||
|
||||
|
@ -719,7 +732,7 @@ describe('array', function () {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('should allow nested arrays', function(done) {
|
||||
it('should allow nested arrays', function (done) {
|
||||
|
||||
var schema = Joi.array().items(Joi.array().items(Joi.number())).single();
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ describe('date', function () {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('accepts "now" as the min date', function(done) {
|
||||
it('accepts "now" as the min date', function (done) {
|
||||
|
||||
var future = new Date(Date.now() + 1000000);
|
||||
|
||||
|
@ -102,7 +102,7 @@ describe('date', function () {
|
|||
});
|
||||
});
|
||||
|
||||
it('errors if .min("now") is used with a past date', function(done) {
|
||||
it('errors if .min("now") is used with a past date', function (done) {
|
||||
|
||||
var past = new Date(Date.now() - 1000000);
|
||||
|
||||
|
@ -113,7 +113,7 @@ describe('date', function () {
|
|||
});
|
||||
});
|
||||
|
||||
it('accepts references as min date', function(done) {
|
||||
it('accepts references as min date', function (done) {
|
||||
|
||||
var schema = Joi.object({ a: Joi.date(), b: Joi.date().min(Joi.ref('a')) });
|
||||
var now = Date.now();
|
||||
|
@ -125,14 +125,38 @@ describe('date', function () {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('errors if reference is not a date', function(done) {
|
||||
it('accepts context references as min date', function (done) {
|
||||
|
||||
var schema = Joi.object({ a: Joi.string(), b: Joi.date().min(Joi.ref('a')) });
|
||||
var schema = Joi.object({ b: Joi.date().min(Joi.ref('$a')) });
|
||||
var now = Date.now();
|
||||
|
||||
Helper.validate(schema, [
|
||||
[{ a: 'abc', b: new Date() }, false, null, 'child "b" fails because ["b" references "a" which is not a date]'],
|
||||
[{ a: '123', b: new Date() }, true],
|
||||
[{ a: (Date.now() + 1e3).toString(), b: new Date() }, false, null, /^child "b" fails because \["b" must be larger than or equal to/]
|
||||
[{ b: now }, true, { context: { a: now } }],
|
||||
[{ b: now + 1e3 }, true, { context: { a: now } }],
|
||||
[{ b: now - 1e3 }, false, { context: { a: now } }]
|
||||
], done);
|
||||
});
|
||||
|
||||
it('errors if reference is not a date', function (done) {
|
||||
|
||||
var schema = Joi.object({ a: Joi.string(), b: Joi.date().min(Joi.ref('a')) });
|
||||
var now = Date.now();
|
||||
|
||||
Helper.validate(schema, [
|
||||
[{ a: 'abc', b: now }, false, null, 'child "b" fails because ["b" references "a" which is not a date]'],
|
||||
[{ a: '123', b: now }, true],
|
||||
[{ a: (now + 1e3).toString(), b: now }, false, null, /^child "b" fails because \["b" must be larger than or equal to/]
|
||||
], done);
|
||||
});
|
||||
|
||||
it('errors if context reference is not a date', function (done) {
|
||||
|
||||
var schema = Joi.object({ b: Joi.date().min(Joi.ref('$a')) });
|
||||
var now = Date.now();
|
||||
|
||||
Helper.validate(schema, [
|
||||
[{ b: now }, false, { context: { a: 'abc' } }, 'child "b" fails because ["b" references "a" which is not a date]'],
|
||||
[{ b: now }, false, { context: { a: (now + 1e3).toString() } }, /^child "b" fails because \["b" must be larger than or equal to/]
|
||||
], done);
|
||||
});
|
||||
});
|
||||
|
@ -152,30 +176,30 @@ describe('date', function () {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('accepts "now" as the max date', function(done) {
|
||||
it('accepts "now" as the max date', function (done) {
|
||||
|
||||
var past = new Date(Date.now() - 1000000);
|
||||
var past = new Date(Date.now() - 1000000);
|
||||
|
||||
Joi.date().max('now').validate(past, function (err, value) {
|
||||
Joi.date().max('now').validate(past, function (err, value) {
|
||||
|
||||
expect(err).to.not.exist();
|
||||
expect(value).to.deep.equal(past);
|
||||
done();
|
||||
});
|
||||
expect(err).to.not.exist();
|
||||
expect(value).to.deep.equal(past);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('errors if .max("now") is used with a future date', function(done) {
|
||||
it('errors if .max("now") is used with a future date', function (done) {
|
||||
|
||||
var future = new Date(Date.now() + 1000000);
|
||||
var future = new Date(Date.now() + 1000000);
|
||||
|
||||
Joi.date().max('now').validate(future, function (err, value) {
|
||||
Joi.date().max('now').validate(future, function (err, value) {
|
||||
|
||||
expect(err).to.exist();
|
||||
done();
|
||||
});
|
||||
expect(err).to.exist();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('accepts references as max date', function(done) {
|
||||
it('accepts references as max date', function (done) {
|
||||
|
||||
var schema = Joi.object({ a: Joi.date(), b: Joi.date().max(Joi.ref('a')) });
|
||||
var now = Date.now();
|
||||
|
@ -187,14 +211,39 @@ describe('date', function () {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('errors if reference is not a date', function(done) {
|
||||
it('accepts references as max date', function (done) {
|
||||
|
||||
var schema = Joi.object({ b: Joi.date().max(Joi.ref('$a')) });
|
||||
var now = Date.now();
|
||||
|
||||
Helper.validate(schema, [
|
||||
[{ b: now }, true, { context: { a: now } }],
|
||||
[{ b: now + 1e3 }, false, { context: { a: now } }],
|
||||
[{ b: now - 1e3 }, true, { context: { a: now } }]
|
||||
], done);
|
||||
});
|
||||
|
||||
it('errors if reference is not a date', function (done) {
|
||||
|
||||
var schema = Joi.object({ a: Joi.string(), b: Joi.date().max(Joi.ref('a')) });
|
||||
var now = Date.now();
|
||||
|
||||
Helper.validate(schema, [
|
||||
[{ a: 'abc', b: new Date() }, false, null, 'child "b" fails because ["b" references "a" which is not a date]'],
|
||||
[{ a: '100000000000000', b: new Date() }, true],
|
||||
[{ a: (Date.now() - 1e3).toString(), b: new Date() }, false, null, /^child "b" fails because \["b" must be less than or equal to/]
|
||||
[{ a: '100000000000000', b: now }, true],
|
||||
[{ a: (now - 1e3).toString(), b: now }, false, null, /^child "b" fails because \["b" must be less than or equal to/]
|
||||
], done);
|
||||
});
|
||||
|
||||
it('errors if context reference is not a date', function (done) {
|
||||
|
||||
var schema = Joi.object({ b: Joi.date().max(Joi.ref('$a')) });
|
||||
var now = Date.now();
|
||||
|
||||
Helper.validate(schema, [
|
||||
[{ b: now }, false, { context: { a: 'abc' } }, 'child "b" fails because ["b" references "a" which is not a date]'],
|
||||
[{ b: now }, true, { context: { a: '100000000000000' } }],
|
||||
[{ b: now }, false, { context: { a: (now - 1e3).toString() } }, /^child "b" fails because \["b" must be less than or equal to/]
|
||||
], done);
|
||||
});
|
||||
});
|
||||
|
@ -208,7 +257,7 @@ describe('date', function () {
|
|||
], done);
|
||||
});
|
||||
|
||||
describe('#iso', function() {
|
||||
describe('#iso', function () {
|
||||
|
||||
it('validates isoDate', function (done) {
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ describe('errors', function () {
|
|||
|
||||
expect(err).to.exist();
|
||||
expect(err.name).to.equal('ValidationError');
|
||||
expect(err.message).to.equal('"value" 11. "required" 7. "xor" 7. child "email" fails because ["email" 19]. child "date" fails because ["date" 18]. child "alphanum" fails because ["alphanum" 16]. child "min" fails because ["min" 14]. child "max" fails because ["max" 15]. child "notEmpty" fails because ["notEmpty" 3]');
|
||||
expect(err.message).to.equal('"value" 11. child "email" fails because ["email" 19]. child "date" fails because ["date" 18]. child "alphanum" fails because ["alphanum" 16]. child "min" fails because ["min" 14]. child "max" fails because ["max" 15]. child "notEmpty" fails because ["notEmpty" 3]. "required" 7. "xor" 7');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -288,7 +288,7 @@ describe('errors', function () {
|
|||
|
||||
it('annotates circular input', function (done) {
|
||||
|
||||
var schema = {
|
||||
var schema = {
|
||||
x: Joi.object({
|
||||
y: Joi.object({
|
||||
z: Joi.number()
|
||||
|
@ -309,7 +309,7 @@ describe('errors', function () {
|
|||
|
||||
it('annotates deep circular input', function (done) {
|
||||
|
||||
var schema = {
|
||||
var schema = {
|
||||
x: Joi.object({
|
||||
y: Joi.object({
|
||||
z: Joi.number()
|
||||
|
@ -330,7 +330,7 @@ describe('errors', function () {
|
|||
|
||||
it('annotates deep circular input with extra keys', function (done) {
|
||||
|
||||
var schema = {
|
||||
var schema = {
|
||||
x: Joi.object({
|
||||
y: Joi.object({
|
||||
z: Joi.number()
|
||||
|
|
|
@ -1231,7 +1231,7 @@ describe('Joi', function () {
|
|||
});
|
||||
});
|
||||
|
||||
it('errors multiple times when abortEarly is false in a complex object', function(done) {
|
||||
it('errors multiple times when abortEarly is false in a complex object', function (done) {
|
||||
|
||||
var schema = Joi.object({
|
||||
test: Joi.array().items(Joi.object().keys({
|
||||
|
@ -1276,6 +1276,7 @@ describe('Joi', function () {
|
|||
};
|
||||
|
||||
Joi.validate(value, schema, { abortEarly: false }, function (err, value) {
|
||||
|
||||
expect(err).to.exist();
|
||||
expect(err.details).to.have.length(6);
|
||||
expect(err.details).to.deep.equal([{
|
||||
|
@ -1412,6 +1413,7 @@ describe('Joi', function () {
|
|||
xor: Joi.string(),
|
||||
renamed: Joi.string().valid('456'),
|
||||
notEmpty: Joi.string().required().description('a').notes('b').tags('c'),
|
||||
empty: Joi.string().empty('').strip(),
|
||||
defaultRef: Joi.string().default(defaultRef, 'not here'),
|
||||
defaultFn: Joi.string().default(defaultFn, 'not here'),
|
||||
defaultDescribedFn: Joi.string().default(defaultDescribedFn, 'described test')
|
||||
|
@ -1491,6 +1493,20 @@ describe('Joi', function () {
|
|||
tags: ['c'],
|
||||
invalids: ['']
|
||||
},
|
||||
empty: {
|
||||
type: 'string',
|
||||
flags: {
|
||||
empty: {
|
||||
type: 'string',
|
||||
flags: {
|
||||
allowOnly: true
|
||||
},
|
||||
valids: ['']
|
||||
},
|
||||
strip: true
|
||||
},
|
||||
invalids: ['']
|
||||
},
|
||||
defaultRef: {
|
||||
type: 'string',
|
||||
flags: {
|
||||
|
|
|
@ -70,7 +70,7 @@ describe('number', function () {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('should return false for Infinity', function(done) {
|
||||
it('should return false for Infinity', function (done) {
|
||||
|
||||
var t = Joi.number();
|
||||
Helper.validate(t, [
|
||||
|
@ -79,7 +79,7 @@ describe('number', function () {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('should return true for allowed Infinity', function(done) {
|
||||
it('should return true for allowed Infinity', function (done) {
|
||||
|
||||
var t = Joi.number().allow(Infinity, -Infinity);
|
||||
Helper.validate(t, [
|
||||
|
@ -538,7 +538,7 @@ describe('number', function () {
|
|||
});
|
||||
});
|
||||
|
||||
it('accepts references as min value', function(done) {
|
||||
it('accepts references as min value', function (done) {
|
||||
|
||||
var schema = Joi.object({ a: Joi.number(), b: Joi.number().min(Joi.ref('a')) });
|
||||
|
||||
|
@ -553,7 +553,21 @@ describe('number', function () {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('errors if reference is not a number', function(done) {
|
||||
it('accepts context references as min value', function (done) {
|
||||
|
||||
var schema = Joi.object({ b: Joi.number().min(Joi.ref('$a')) });
|
||||
|
||||
Helper.validate(schema, [
|
||||
[{ b: 1337 }, true, { context: { a: 42 } }],
|
||||
[{ b: 42 }, false, { context: { a: 1337 } }],
|
||||
[{ b: 4.2 }, true, { context: { a: 2.4 } }],
|
||||
[{ b: 4.20000001 }, true, { context: { a: 4.2 } }],
|
||||
[{ b: 4.2 }, false, { context: { a: 4.20000001 } }],
|
||||
[{ b: 2.4 }, false, { context: { a: 4.2 } }, 'child "b" fails because ["b" must be larger than or equal to 4.2]']
|
||||
], done);
|
||||
});
|
||||
|
||||
it('errors if reference is not a number', function (done) {
|
||||
|
||||
var schema = Joi.object({ a: Joi.string(), b: Joi.number().min(Joi.ref('a')) });
|
||||
|
||||
|
@ -561,6 +575,15 @@ describe('number', function () {
|
|||
[{ a: 'abc', b: 42 }, false, null, 'child "b" fails because ["b" references "a" which is not a number]']
|
||||
], done);
|
||||
});
|
||||
|
||||
it('errors if context reference is not a number', function (done) {
|
||||
|
||||
var schema = Joi.object({ b: Joi.number().min(Joi.ref('$a')) });
|
||||
|
||||
Helper.validate(schema, [
|
||||
[{ b: 42 }, false, { context: { a: 'abc' } }, 'child "b" fails because ["b" references "a" which is not a number]']
|
||||
], done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#max', function () {
|
||||
|
@ -574,7 +597,7 @@ describe('number', function () {
|
|||
done();
|
||||
});
|
||||
|
||||
it('accepts references as max value', function(done) {
|
||||
it('accepts references as max value', function (done) {
|
||||
|
||||
var schema = Joi.object({ a: Joi.number(), b: Joi.number().max(Joi.ref('a')) });
|
||||
|
||||
|
@ -589,7 +612,21 @@ describe('number', function () {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('errors if reference is not a number', function(done) {
|
||||
it('accepts context references as max value', function (done) {
|
||||
|
||||
var schema = Joi.object({ b: Joi.number().max(Joi.ref('$a')) });
|
||||
|
||||
Helper.validate(schema, [
|
||||
[{ b: 42 }, true, { context: { a: 1337 } }],
|
||||
[{ b: 1337 }, false, { context: { a: 42 } }],
|
||||
[{ b: 2.4 }, true, { context: { a: 4.2 } }],
|
||||
[{ b: 4.20000001 }, false, { context: { a: 4.2 } }],
|
||||
[{ b: 4.2 }, true, { context: { a: 4.20000001 } }],
|
||||
[{ b: 4.2 }, false, { context: { a: 2.4 } }, 'child "b" fails because ["b" must be less than or equal to 2.4]']
|
||||
], done);
|
||||
});
|
||||
|
||||
it('errors if reference is not a number', function (done) {
|
||||
|
||||
var schema = Joi.object({ a: Joi.string(), b: Joi.number().max(Joi.ref('a')) });
|
||||
|
||||
|
@ -597,6 +634,15 @@ describe('number', function () {
|
|||
[{ a: 'abc', b: 42 }, false, null, 'child "b" fails because ["b" references "a" which is not a number]']
|
||||
], done);
|
||||
});
|
||||
|
||||
it('errors if context reference is not a number', function (done) {
|
||||
|
||||
var schema = Joi.object({ b: Joi.number().max(Joi.ref('$a')) });
|
||||
|
||||
Helper.validate(schema, [
|
||||
[{ b: 42 }, false, { context: { a: 'abc' } }, 'child "b" fails because ["b" references "a" which is not a number]']
|
||||
], done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#less', function () {
|
||||
|
@ -610,7 +656,7 @@ describe('number', function () {
|
|||
done();
|
||||
});
|
||||
|
||||
it('accepts references as less value', function(done) {
|
||||
it('accepts references as less value', function (done) {
|
||||
|
||||
var schema = Joi.object({ a: Joi.number(), b: Joi.number().less(Joi.ref('a')) });
|
||||
|
||||
|
@ -625,7 +671,21 @@ describe('number', function () {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('errors if reference is not a number', function(done) {
|
||||
it('accepts context references as less value', function (done) {
|
||||
|
||||
var schema = Joi.object({ b: Joi.number().less(Joi.ref('$a')) });
|
||||
|
||||
Helper.validate(schema, [
|
||||
[{ b: 42 }, true, { context: { a: 1337 } }],
|
||||
[{ b: 1337 }, false, { context: { a: 42 } }],
|
||||
[{ b: 2.4 }, true, { context: { a: 4.2 } }],
|
||||
[{ b: 4.20000001 }, false, { context: { a: 4.2 } }],
|
||||
[{ b: 4.2 }, true, { context: { a: 4.20000001 } }],
|
||||
[{ b: 4.2 }, false, { context: { a: 2.4 } }, 'child "b" fails because ["b" must be less than 2.4]']
|
||||
], done);
|
||||
});
|
||||
|
||||
it('errors if reference is not a number', function (done) {
|
||||
|
||||
var schema = Joi.object({ a: Joi.string(), b: Joi.number().less(Joi.ref('a')) });
|
||||
|
||||
|
@ -633,6 +693,15 @@ describe('number', function () {
|
|||
[{ a: 'abc', b: 42 }, false, null, 'child "b" fails because ["b" references "a" which is not a number]']
|
||||
], done);
|
||||
});
|
||||
|
||||
it('errors if context reference is not a number', function (done) {
|
||||
|
||||
var schema = Joi.object({ a: Joi.string(), b: Joi.number().less(Joi.ref('$a')) });
|
||||
|
||||
Helper.validate(schema, [
|
||||
[{ b: 42 }, false, { context: { a: 'abc' } }, 'child "b" fails because ["b" references "a" which is not a number]']
|
||||
], done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#greater', function () {
|
||||
|
@ -646,7 +715,7 @@ describe('number', function () {
|
|||
done();
|
||||
});
|
||||
|
||||
it('accepts references as greater value', function(done) {
|
||||
it('accepts references as greater value', function (done) {
|
||||
|
||||
var schema = Joi.object({ a: Joi.number(), b: Joi.number().greater(Joi.ref('a')) });
|
||||
|
||||
|
@ -661,7 +730,21 @@ describe('number', function () {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('errors if reference is not a number', function(done) {
|
||||
it('accepts context references as greater value', function (done) {
|
||||
|
||||
var schema = Joi.object({ b: Joi.number().greater(Joi.ref('$a')) });
|
||||
|
||||
Helper.validate(schema, [
|
||||
[{ b: 1337 }, true, { context: { a: 42 } }],
|
||||
[{ b: 42 }, false, { context: { a: 1337 } }],
|
||||
[{ b: 4.2 }, true, { context: { a: 2.4 } }],
|
||||
[{ b: 4.20000001 }, true, { context: { a: 4.2 } }],
|
||||
[{ b: 4.2 }, false, { context: { a: 4.20000001 } }],
|
||||
[{ b: 2.4 }, false, { context: { a: 4.2 } }, 'child "b" fails because ["b" must be greater than 4.2]']
|
||||
], done);
|
||||
});
|
||||
|
||||
it('errors if reference is not a number', function (done) {
|
||||
|
||||
var schema = Joi.object({ a: Joi.string(), b: Joi.number().greater(Joi.ref('a')) });
|
||||
|
||||
|
@ -669,6 +752,15 @@ describe('number', function () {
|
|||
[{ a: 'abc', b: 42 }, false, null, 'child "b" fails because ["b" references "a" which is not a number]']
|
||||
], done);
|
||||
});
|
||||
|
||||
it('errors if context reference is not a number', function (done) {
|
||||
|
||||
var schema = Joi.object({ b: Joi.number().greater(Joi.ref('$a')) });
|
||||
|
||||
Helper.validate(schema, [
|
||||
[{ b: 42 }, false, { context: { a: 'abc' } }, 'child "b" fails because ["b" references "a" which is not a number]']
|
||||
], done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#precision', function (done) {
|
||||
|
@ -707,7 +799,7 @@ describe('number', function () {
|
|||
});
|
||||
});
|
||||
|
||||
describe('#multiple', function() {
|
||||
describe('#multiple', function () {
|
||||
|
||||
it('throws when multiple is not a number', function (done) {
|
||||
|
||||
|
|
|
@ -686,7 +686,7 @@ describe('object', function () {
|
|||
});
|
||||
});
|
||||
|
||||
it('should ignore a key with ignoredUndefined if from does not exist', function(done){
|
||||
it('should ignore a key with ignoredUndefined if from does not exist', function (done){
|
||||
|
||||
var schema = Joi.object().rename('b', 'a', { ignoreUndefined: true });
|
||||
|
||||
|
@ -702,7 +702,7 @@ describe('object', function () {
|
|||
});
|
||||
});
|
||||
|
||||
it('shouldn\'t delete a key with override and ignoredUndefined if from does not exist', function(done){
|
||||
it('shouldn\'t delete a key with override and ignoredUndefined if from does not exist', function (done){
|
||||
|
||||
var schema = Joi.object().rename('b', 'a', { ignoreUndefined: true, override: true });
|
||||
|
||||
|
|
|
@ -165,7 +165,7 @@ describe('string', function () {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('accepts references as min length', function(done) {
|
||||
it('accepts references as min length', function (done) {
|
||||
|
||||
var schema = Joi.object({ a: Joi.number(), b: Joi.string().min(Joi.ref('a'), 'utf8') });
|
||||
Helper.validate(schema, [
|
||||
|
@ -175,7 +175,17 @@ describe('string', function () {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('errors if reference is not a number', function(done) {
|
||||
it('accepts context references as min length', function (done) {
|
||||
|
||||
var schema = Joi.object({ b: Joi.string().min(Joi.ref('$a'), 'utf8') });
|
||||
Helper.validate(schema, [
|
||||
[{ b: '\u00bd' }, true, { context: { a: 2 } }],
|
||||
[{ b: 'a' }, false, { context: { a: 2 } }],
|
||||
[{ b: 'a' }, false, { context: { a: 2 } }, 'child "b" fails because ["b" length must be at least 2 characters long]']
|
||||
], done);
|
||||
});
|
||||
|
||||
it('errors if reference is not a number', function (done) {
|
||||
|
||||
var schema = Joi.object({ a: Joi.any(), b: Joi.string().min(Joi.ref('a'), 'utf8') });
|
||||
|
||||
|
@ -183,6 +193,15 @@ describe('string', function () {
|
|||
[{ a: 'Hi there', b: '\u00bd' }, false, null, 'child "b" fails because ["b" references "a" which is not a number]']
|
||||
], done);
|
||||
});
|
||||
|
||||
it('errors if context reference is not a number', function (done) {
|
||||
|
||||
var schema = Joi.object({ b: Joi.string().min(Joi.ref('$a'), 'utf8') });
|
||||
|
||||
Helper.validate(schema, [
|
||||
[{ b: '\u00bd' }, false, { context: { a: 'Hi there' } }, 'child "b" fails because ["b" references "a" which is not a number]']
|
||||
], done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#max', function () {
|
||||
|
@ -223,7 +242,7 @@ describe('string', function () {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('accepts references as min length', function(done) {
|
||||
it('accepts references as min length', function (done) {
|
||||
|
||||
var schema = Joi.object({ a: Joi.number(), b: Joi.string().max(Joi.ref('a'), 'utf8') });
|
||||
Helper.validate(schema, [
|
||||
|
@ -233,7 +252,17 @@ describe('string', function () {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('errors if reference is not a number', function(done) {
|
||||
it('accepts context references as min length', function (done) {
|
||||
|
||||
var schema = Joi.object({ b: Joi.string().max(Joi.ref('$a'), 'utf8') });
|
||||
Helper.validate(schema, [
|
||||
[{ b: '\u00bd' }, true, { context: { a: 2 } }],
|
||||
[{ b: 'three' }, false, { context: { a: 2 } }],
|
||||
[{ b: 'three' }, false, { context: { a: 2 } }, 'child "b" fails because ["b" length must be less than or equal to 2 characters long]']
|
||||
], done);
|
||||
});
|
||||
|
||||
it('errors if reference is not a number', function (done) {
|
||||
|
||||
var schema = Joi.object({ a: Joi.any(), b: Joi.string().max(Joi.ref('a'), 'utf8') });
|
||||
|
||||
|
@ -241,6 +270,15 @@ describe('string', function () {
|
|||
[{ a: 'Hi there', b: '\u00bd' }, false, null, 'child "b" fails because ["b" references "a" which is not a number]']
|
||||
], done);
|
||||
});
|
||||
|
||||
it('errors if context reference is not a number', function (done) {
|
||||
|
||||
var schema = Joi.object({ b: Joi.string().max(Joi.ref('$a'), 'utf8') });
|
||||
|
||||
Helper.validate(schema, [
|
||||
[{ b: '\u00bd' }, false, { context: { a: 'Hi there' } }, 'child "b" fails because ["b" references "a" which is not a number]']
|
||||
], done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#creditCard', function () {
|
||||
|
@ -318,7 +356,7 @@ describe('string', function () {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('accepts references as length', function(done) {
|
||||
it('accepts references as length', function (done) {
|
||||
|
||||
var schema = Joi.object({ a: Joi.number(), b: Joi.string().length(Joi.ref('a'), 'utf8') });
|
||||
Helper.validate(schema, [
|
||||
|
@ -328,7 +366,17 @@ describe('string', function () {
|
|||
], done);
|
||||
});
|
||||
|
||||
it('errors if reference is not a number', function(done) {
|
||||
it('accepts context references as length', function (done) {
|
||||
|
||||
var schema = Joi.object({ b: Joi.string().length(Joi.ref('$a'), 'utf8') });
|
||||
Helper.validate(schema, [
|
||||
[{ b: '\u00bd' }, true, { context: { a: 2 } }],
|
||||
[{ b: 'a' }, false, { context: { a: 2 } }],
|
||||
[{ b: 'a' }, false, { context: { a: 2 } }, 'child "b" fails because ["b" length must be 2 characters long]']
|
||||
], done);
|
||||
});
|
||||
|
||||
it('errors if reference is not a number', function (done) {
|
||||
|
||||
var schema = Joi.object({ a: Joi.any(), b: Joi.string().length(Joi.ref('a'), 'utf8') });
|
||||
|
||||
|
@ -336,10 +384,21 @@ describe('string', function () {
|
|||
[{ a: 'Hi there', b: '\u00bd' }, false, null, 'child "b" fails because ["b" references "a" which is not a number]']
|
||||
], done);
|
||||
});
|
||||
|
||||
it('errors if context reference is not a number', function (done) {
|
||||
|
||||
var schema = Joi.object({ a: Joi.any(), b: Joi.string().length(Joi.ref('$a'), 'utf8') });
|
||||
|
||||
Helper.validate(schema, [
|
||||
[{ b: '\u00bd' }, false, { context: { a: 'Hi there' } }, 'child "b" fails because ["b" references "a" which is not a number]']
|
||||
], done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#email', function() {
|
||||
describe('#email', function () {
|
||||
|
||||
it('throws when options are not an object', function (done) {
|
||||
|
||||
expect(function () {
|
||||
|
||||
var emailOptions = true;
|
||||
|
@ -349,6 +408,7 @@ describe('string', function () {
|
|||
});
|
||||
|
||||
it('throws when checkDNS option is enabled', function (done) {
|
||||
|
||||
expect(function () {
|
||||
|
||||
var emailOptions = {checkDNS: true};
|
||||
|
@ -358,6 +418,7 @@ describe('string', function () {
|
|||
});
|
||||
|
||||
it('throws when tldWhitelist is not an array or object', function (done) {
|
||||
|
||||
expect(function () {
|
||||
|
||||
var emailOptions = {tldWhitelist: 'domain.tld'};
|
||||
|
@ -367,6 +428,7 @@ describe('string', function () {
|
|||
});
|
||||
|
||||
it('throws when minDomainAtoms is not a number', function (done) {
|
||||
|
||||
expect(function () {
|
||||
|
||||
var emailOptions = {minDomainAtoms: '1'};
|
||||
|
@ -376,6 +438,7 @@ describe('string', function () {
|
|||
});
|
||||
|
||||
it('throws when minDomainAtoms is not an integer', function (done) {
|
||||
|
||||
expect(function () {
|
||||
|
||||
var emailOptions = {minDomainAtoms: 1.2};
|
||||
|
@ -385,6 +448,7 @@ describe('string', function () {
|
|||
});
|
||||
|
||||
it('throws when minDomainAtoms is not positive', function (done) {
|
||||
|
||||
expect(function () {
|
||||
|
||||
var emailOptions = {minDomainAtoms: 0};
|
||||
|
@ -394,6 +458,7 @@ describe('string', function () {
|
|||
});
|
||||
|
||||
it('does not throw when minDomainAtoms is a positive integer', function (done) {
|
||||
|
||||
expect(function () {
|
||||
|
||||
var emailOptions = {minDomainAtoms: 1};
|
||||
|
@ -403,6 +468,7 @@ describe('string', function () {
|
|||
});
|
||||
|
||||
it('throws when errorLevel is not an integer or boolean', function (done) {
|
||||
|
||||
expect(function () {
|
||||
|
||||
var emailOptions = {errorLevel: 1.2};
|
||||
|
@ -412,6 +478,7 @@ describe('string', function () {
|
|||
});
|
||||
|
||||
it('throws when errorLevel is negative', function (done) {
|
||||
|
||||
expect(function () {
|
||||
|
||||
var emailOptions = {errorLevel: -1};
|
||||
|
@ -421,6 +488,7 @@ describe('string', function () {
|
|||
});
|
||||
|
||||
it('does not throw when errorLevel is 0', function (done) {
|
||||
|
||||
expect(function () {
|
||||
|
||||
var emailOptions = {errorLevel: 0};
|
||||
|
@ -653,7 +721,7 @@ describe('string', function () {
|
|||
['v1.09azAZ-._~!$&\'()*+,;=:/33', false],
|
||||
['v1.09#', false]
|
||||
],
|
||||
validIPv4sWithCidr = function(success) {
|
||||
validIPv4sWithCidr = function (success) {
|
||||
|
||||
return [
|
||||
['0.0.0.0/32', success],
|
||||
|
@ -672,7 +740,7 @@ describe('string', function () {
|
|||
['000.000.000.000/32', success]
|
||||
];
|
||||
},
|
||||
validIPv4sWithoutCidr = function(success) {
|
||||
validIPv4sWithoutCidr = function (success) {
|
||||
|
||||
return [
|
||||
['0.0.0.0', success],
|
||||
|
@ -724,7 +792,7 @@ describe('string', function () {
|
|||
];
|
||||
};
|
||||
|
||||
it('should validate all ip addresses with optional CIDR by default', function(done) {
|
||||
it('should validate all ip addresses with optional CIDR by default', function (done) {
|
||||
|
||||
var schema = Joi.string().ip();
|
||||
Helper.validate(schema, []
|
||||
|
@ -740,7 +808,7 @@ describe('string', function () {
|
|||
.concat(invalidIPvFutures), done);
|
||||
});
|
||||
|
||||
it('should validate all ip addresses with an optional CIDR', function(done) {
|
||||
it('should validate all ip addresses with an optional CIDR', function (done) {
|
||||
|
||||
var schema = Joi.string().ip({ cidr: 'optional' });
|
||||
Helper.validate(schema, []
|
||||
|
@ -756,7 +824,7 @@ describe('string', function () {
|
|||
.concat(invalidIPvFutures), done);
|
||||
});
|
||||
|
||||
it('should validate all ip addresses with a required CIDR', function(done) {
|
||||
it('should validate all ip addresses with a required CIDR', function (done) {
|
||||
|
||||
var schema = Joi.string().ip({ cidr: 'required' });
|
||||
Helper.validate(schema, []
|
||||
|
@ -772,7 +840,7 @@ describe('string', function () {
|
|||
.concat(invalidIPvFutures), done);
|
||||
});
|
||||
|
||||
it('should validate all ip addresses with a forbidden CIDR', function(done) {
|
||||
it('should validate all ip addresses with a forbidden CIDR', function (done) {
|
||||
|
||||
var schema = Joi.string().ip({ cidr: 'forbidden' });
|
||||
Helper.validate(schema, []
|
||||
|
@ -872,9 +940,9 @@ describe('string', function () {
|
|||
});
|
||||
});
|
||||
|
||||
describe('#ip({ version: "ipv4" })', function() {
|
||||
describe('#ip({ version: "ipv4" })', function () {
|
||||
|
||||
it('should validate all ipv4 addresses with a default CIDR strategy', function(done) {
|
||||
it('should validate all ipv4 addresses with a default CIDR strategy', function (done) {
|
||||
|
||||
var schema = Joi.string().ip({ version: 'ipv4' });
|
||||
Helper.validate(schema, []
|
||||
|
@ -890,7 +958,7 @@ describe('string', function () {
|
|||
.concat(invalidIPvFutures), done);
|
||||
});
|
||||
|
||||
it('should validate all ipv4 addresses with an optional CIDR', function(done) {
|
||||
it('should validate all ipv4 addresses with an optional CIDR', function (done) {
|
||||
|
||||
var schema = Joi.string().ip({ version: 'ipv4', cidr: 'optional' });
|
||||
Helper.validate(schema, []
|
||||
|
@ -906,7 +974,7 @@ describe('string', function () {
|
|||
.concat(invalidIPvFutures), done);
|
||||
});
|
||||
|
||||
it('should validate all ipv4 addresses with a required CIDR', function(done) {
|
||||
it('should validate all ipv4 addresses with a required CIDR', function (done) {
|
||||
|
||||
var schema = Joi.string().ip({ version: 'ipv4', cidr: 'required' });
|
||||
Helper.validate(schema, []
|
||||
|
@ -922,7 +990,7 @@ describe('string', function () {
|
|||
.concat(invalidIPvFutures), done);
|
||||
});
|
||||
|
||||
it('should validate all ipv4 addresses with a forbidden CIDR', function(done) {
|
||||
it('should validate all ipv4 addresses with a forbidden CIDR', function (done) {
|
||||
|
||||
var schema = Joi.string().ip({ version: 'ipv4', cidr: 'forbidden' });
|
||||
Helper.validate(schema, []
|
||||
|
@ -939,9 +1007,9 @@ describe('string', function () {
|
|||
});
|
||||
});
|
||||
|
||||
describe('#ip({ version: "ipv6" })', function() {
|
||||
describe('#ip({ version: "ipv6" })', function () {
|
||||
|
||||
it('should validate all ipv6 addresses with a default CIDR strategy', function(done) {
|
||||
it('should validate all ipv6 addresses with a default CIDR strategy', function (done) {
|
||||
|
||||
var schema = Joi.string().ip({ version: 'ipv6' });
|
||||
Helper.validate(schema, []
|
||||
|
@ -957,7 +1025,7 @@ describe('string', function () {
|
|||
.concat(invalidIPvFutures), done);
|
||||
});
|
||||
|
||||
it('should validate all ipv6 addresses with an optional CIDR', function(done) {
|
||||
it('should validate all ipv6 addresses with an optional CIDR', function (done) {
|
||||
|
||||
var schema = Joi.string().ip({ version: 'ipv6', cidr: 'optional' });
|
||||
Helper.validate(schema, []
|
||||
|
@ -973,7 +1041,7 @@ describe('string', function () {
|
|||
.concat(invalidIPvFutures), done);
|
||||
});
|
||||
|
||||
it('should validate all ipv6 addresses with a required CIDR', function(done) {
|
||||
it('should validate all ipv6 addresses with a required CIDR', function (done) {
|
||||
|
||||
var schema = Joi.string().ip({ version: 'ipv6', cidr: 'required' });
|
||||
Helper.validate(schema, []
|
||||
|
@ -989,7 +1057,7 @@ describe('string', function () {
|
|||
.concat(invalidIPvFutures), done);
|
||||
});
|
||||
|
||||
it('should validate all ipv6 addresses with a forbidden CIDR', function(done) {
|
||||
it('should validate all ipv6 addresses with a forbidden CIDR', function (done) {
|
||||
|
||||
var schema = Joi.string().ip({ version: 'ipv6', cidr: 'forbidden' });
|
||||
Helper.validate(schema, []
|
||||
|
@ -1006,9 +1074,9 @@ describe('string', function () {
|
|||
});
|
||||
});
|
||||
|
||||
describe('#ip({ version: "ipvfuture" })', function() {
|
||||
describe('#ip({ version: "ipvfuture" })', function () {
|
||||
|
||||
it('should validate all ipvfuture addresses with a default CIDR strategy', function(done) {
|
||||
it('should validate all ipvfuture addresses with a default CIDR strategy', function (done) {
|
||||
|
||||
var schema = Joi.string().ip({ version: 'ipvfuture' });
|
||||
Helper.validate(schema, []
|
||||
|
@ -1024,7 +1092,7 @@ describe('string', function () {
|
|||
.concat(invalidIPvFutures), done);
|
||||
});
|
||||
|
||||
it('should validate all ipvfuture addresses with an optional CIDR', function(done) {
|
||||
it('should validate all ipvfuture addresses with an optional CIDR', function (done) {
|
||||
|
||||
var schema = Joi.string().ip({ version: 'ipvfuture', cidr: 'optional' });
|
||||
Helper.validate(schema, []
|
||||
|
@ -1040,7 +1108,7 @@ describe('string', function () {
|
|||
.concat(invalidIPvFutures), done);
|
||||
});
|
||||
|
||||
it('should validate all ipvfuture addresses with a required CIDR', function(done) {
|
||||
it('should validate all ipvfuture addresses with a required CIDR', function (done) {
|
||||
|
||||
var schema = Joi.string().ip({ version: 'ipvfuture', cidr: 'required' });
|
||||
Helper.validate(schema, []
|
||||
|
@ -1056,7 +1124,7 @@ describe('string', function () {
|
|||
.concat(invalidIPvFutures), done);
|
||||
});
|
||||
|
||||
it('should validate all ipvfuture addresses with a forbidden CIDR', function(done) {
|
||||
it('should validate all ipvfuture addresses with a forbidden CIDR', function (done) {
|
||||
|
||||
var schema = Joi.string().ip({ version: 'ipvfuture', cidr: 'forbidden' });
|
||||
Helper.validate(schema, []
|
||||
|
@ -1073,9 +1141,9 @@ describe('string', function () {
|
|||
});
|
||||
});
|
||||
|
||||
describe('#ip({ version: [ "ipv4", "ipv6" ] })', function() {
|
||||
describe('#ip({ version: [ "ipv4", "ipv6" ] })', function () {
|
||||
|
||||
it('should validate all ipv4 and ipv6 addresses with a default CIDR strategy', function(done) {
|
||||
it('should validate all ipv4 and ipv6 addresses with a default CIDR strategy', function (done) {
|
||||
|
||||
var schema = Joi.string().ip({ version: [ 'ipv4', 'ipv6' ] });
|
||||
Helper.validate(schema, []
|
||||
|
@ -1091,7 +1159,7 @@ describe('string', function () {
|
|||
.concat(invalidIPvFutures), done);
|
||||
});
|
||||
|
||||
it('should validate all ipv4 and ipv6 addresses with an optional CIDR', function(done) {
|
||||
it('should validate all ipv4 and ipv6 addresses with an optional CIDR', function (done) {
|
||||
|
||||
var schema = Joi.string().ip({ version: [ 'ipv4', 'ipv6' ], cidr: 'optional' });
|
||||
Helper.validate(schema, []
|
||||
|
@ -1107,7 +1175,7 @@ describe('string', function () {
|
|||
.concat(invalidIPvFutures), done);
|
||||
});
|
||||
|
||||
it('should validate all ipv4 and ipv6 addresses with a required CIDR', function(done) {
|
||||
it('should validate all ipv4 and ipv6 addresses with a required CIDR', function (done) {
|
||||
|
||||
var schema = Joi.string().ip({ version: [ 'ipv4', 'ipv6' ], cidr: 'required' });
|
||||
Helper.validate(schema, []
|
||||
|
@ -1123,7 +1191,7 @@ describe('string', function () {
|
|||
.concat(invalidIPvFutures), done);
|
||||
});
|
||||
|
||||
it('should validate all ipv4 and ipv6 addresses with a forbidden CIDR', function(done) {
|
||||
it('should validate all ipv4 and ipv6 addresses with a forbidden CIDR', function (done) {
|
||||
|
||||
var schema = Joi.string().ip({ version: [ 'ipv4', 'ipv6' ], cidr: 'forbidden' });
|
||||
Helper.validate(schema, []
|
||||
|
@ -1503,6 +1571,7 @@ describe('string', function () {
|
|||
});
|
||||
|
||||
it('validates combination of null allowed and max', function (done) {
|
||||
|
||||
var rule = Joi.string().allow(null).max(3);
|
||||
Helper.validate(rule, [
|
||||
['x', true],
|
||||
|
@ -1904,7 +1973,7 @@ describe('string', function () {
|
|||
['file:///whatever', true],
|
||||
['mailto:asdf@asdf.com', true],
|
||||
['ftp://www.example.com', true],
|
||||
['javascript:alert(\'hello\');', true],
|
||||
['javascript:alert(\'hello\');', true], // eslint-disable-line no-script-url
|
||||
['xmpp:isaacschlueter@jabber.org', true],
|
||||
['f://some.host/path', true],
|
||||
['http://localhost:18/asdf', true],
|
||||
|
@ -1934,7 +2003,7 @@ describe('string', function () {
|
|||
['dash-test://foo/bar', true],
|
||||
['xmpp:isaacschlueter@jabber.org', true],
|
||||
['http://atpass:foo%40bar@127.0.0.1:8080/path?search=foo#bar', true],
|
||||
['javascript:alert(\'hello\');', true],
|
||||
['javascript:alert(\'hello\');', true], // eslint-disable-line no-script-url
|
||||
['file://localhost/etc/node/', true],
|
||||
['file:///etc/node/', true],
|
||||
['http://USER:PW@www.ExAmPlE.com/', true],
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
3.3.1 / 2015-05-13
|
||||
------------------
|
||||
|
||||
- Added `.sortKeys` dumper option, thanks to @rjmunro.
|
||||
- Fixed astral characters support, #191.
|
||||
|
||||
|
||||
3.3.0 / 2015-04-26
|
||||
------------------
|
||||
|
||||
- Significantly improved long strings formatting in dumper, thanks to @isaacs.
|
||||
- Strip BOM if exists.
|
||||
|
||||
|
||||
3.2.7 / 2015-02-19
|
||||
------------------
|
||||
|
||||
|
|
|
@ -175,6 +175,8 @@ options:
|
|||
block to flow style for collections. -1 means block style everwhere
|
||||
- `styles` - "tag" => "style" map. Each tag may have own set of styles.
|
||||
- `schema` _(default: `DEFAULT_SAFE_SCHEMA`)_ specifies a schema to use.
|
||||
- `sortKeys` _(default: `false`)_ - if `true`, sort keys when dumping YAML. If a
|
||||
function, use the function to sort the keys.
|
||||
|
||||
styles:
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* js-yaml 3.2.7 https://github.com/nodeca/js-yaml */!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.jsyaml=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
||||
/* js-yaml 3.3.1 https://github.com/nodeca/js-yaml */(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.jsyaml = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
||||
'use strict';
|
||||
|
||||
|
||||
|
@ -44,12 +44,12 @@ module.exports.addConstructor = deprecated('addConstructor');
|
|||
|
||||
|
||||
function isNothing(subject) {
|
||||
return (undefined === subject) || (null === subject);
|
||||
return (typeof subject === 'undefined') || (null === subject);
|
||||
}
|
||||
|
||||
|
||||
function isObject(subject) {
|
||||
return ('object' === typeof subject) && (null !== subject);
|
||||
return (typeof subject === 'object') && (null !== subject);
|
||||
}
|
||||
|
||||
|
||||
|
@ -58,9 +58,8 @@ function toArray(sequence) {
|
|||
return sequence;
|
||||
} else if (isNothing(sequence)) {
|
||||
return [];
|
||||
} else {
|
||||
return [ sequence ];
|
||||
}
|
||||
return [ sequence ];
|
||||
}
|
||||
|
||||
|
||||
|
@ -106,17 +105,16 @@ module.exports.extend = extend;
|
|||
},{}],3:[function(require,module,exports){
|
||||
'use strict';
|
||||
|
||||
/*eslint-disable no-use-before-define*/
|
||||
|
||||
var common = require('./common');
|
||||
var YAMLException = require('./exception');
|
||||
var DEFAULT_FULL_SCHEMA = require('./schema/default_full');
|
||||
var DEFAULT_SAFE_SCHEMA = require('./schema/default_safe');
|
||||
|
||||
|
||||
var _toString = Object.prototype.toString;
|
||||
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
|
||||
|
||||
var CHAR_TAB = 0x09; /* Tab */
|
||||
var CHAR_LINE_FEED = 0x0A; /* LF */
|
||||
var CHAR_CARRIAGE_RETURN = 0x0D; /* CR */
|
||||
|
@ -141,7 +139,6 @@ var CHAR_LEFT_CURLY_BRACKET = 0x7B; /* { */
|
|||
var CHAR_VERTICAL_LINE = 0x7C; /* | */
|
||||
var CHAR_RIGHT_CURLY_BRACKET = 0x7D; /* } */
|
||||
|
||||
|
||||
var ESCAPE_SEQUENCES = {};
|
||||
|
||||
ESCAPE_SEQUENCES[0x00] = '\\0';
|
||||
|
@ -160,13 +157,11 @@ ESCAPE_SEQUENCES[0xA0] = '\\_';
|
|||
ESCAPE_SEQUENCES[0x2028] = '\\L';
|
||||
ESCAPE_SEQUENCES[0x2029] = '\\P';
|
||||
|
||||
|
||||
var DEPRECATED_BOOLEANS_SYNTAX = [
|
||||
'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON',
|
||||
'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF'
|
||||
];
|
||||
|
||||
|
||||
function compileStyleMap(schema, map) {
|
||||
var result, keys, index, length, tag, style, type;
|
||||
|
||||
|
@ -197,7 +192,6 @@ function compileStyleMap(schema, map) {
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
function encodeHex(character) {
|
||||
var string, handle, length;
|
||||
|
||||
|
@ -219,13 +213,13 @@ function encodeHex(character) {
|
|||
return '\\' + handle + common.repeat('0', length - string.length) + string;
|
||||
}
|
||||
|
||||
|
||||
function State(options) {
|
||||
this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
|
||||
this.indent = Math.max(1, (options['indent'] || 2));
|
||||
this.skipInvalid = options['skipInvalid'] || false;
|
||||
this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']);
|
||||
this.styleMap = compileStyleMap(this.schema, options['styles'] || null);
|
||||
this.sortKeys = options['sortKeys'] || false;
|
||||
|
||||
this.implicitTypes = this.schema.compiledImplicit;
|
||||
this.explicitTypes = this.schema.compiledExplicit;
|
||||
|
@ -237,6 +231,31 @@ function State(options) {
|
|||
this.usedDuplicates = null;
|
||||
}
|
||||
|
||||
function indentString(string, spaces) {
|
||||
var ind = common.repeat(' ', spaces),
|
||||
position = 0,
|
||||
next = -1,
|
||||
result = '',
|
||||
line,
|
||||
length = string.length;
|
||||
|
||||
while (position < length) {
|
||||
next = string.indexOf('\n', position);
|
||||
if (next === -1) {
|
||||
line = string.slice(position);
|
||||
position = length;
|
||||
} else {
|
||||
line = string.slice(position, next + 1);
|
||||
position = next + 1;
|
||||
}
|
||||
if (line.length && line !== '\n') {
|
||||
result += ind;
|
||||
}
|
||||
result += line;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function generateNextLine(state, level) {
|
||||
return '\n' + common.repeat(' ', state.indent * level);
|
||||
|
@ -256,81 +275,339 @@ function testImplicitResolving(state, str) {
|
|||
return false;
|
||||
}
|
||||
|
||||
function writeScalar(state, object) {
|
||||
var isQuoted, checkpoint, position, length, character, first;
|
||||
function StringBuilder(source) {
|
||||
this.source = source;
|
||||
this.result = '';
|
||||
this.checkpoint = 0;
|
||||
}
|
||||
|
||||
state.dump = '';
|
||||
isQuoted = false;
|
||||
checkpoint = 0;
|
||||
first = object.charCodeAt(0) || 0;
|
||||
StringBuilder.prototype.takeUpTo = function (position) {
|
||||
var er;
|
||||
|
||||
if (-1 !== DEPRECATED_BOOLEANS_SYNTAX.indexOf(object)) {
|
||||
// Ensure compatibility with YAML 1.0/1.1 loaders.
|
||||
isQuoted = true;
|
||||
} else if (0 === object.length) {
|
||||
// Quote empty string
|
||||
isQuoted = true;
|
||||
} else if (CHAR_SPACE === first ||
|
||||
CHAR_SPACE === object.charCodeAt(object.length - 1)) {
|
||||
isQuoted = true;
|
||||
} else if (CHAR_MINUS === first ||
|
||||
CHAR_QUESTION === first) {
|
||||
// Don't check second symbol for simplicity
|
||||
isQuoted = true;
|
||||
if (position < this.checkpoint) {
|
||||
er = new Error('position should be > checkpoint');
|
||||
er.position = position;
|
||||
er.checkpoint = this.checkpoint;
|
||||
throw er;
|
||||
}
|
||||
|
||||
for (position = 0, length = object.length; position < length; position += 1) {
|
||||
character = object.charCodeAt(position);
|
||||
this.result += this.source.slice(this.checkpoint, position);
|
||||
this.checkpoint = position;
|
||||
return this;
|
||||
};
|
||||
|
||||
if (!isQuoted) {
|
||||
if (CHAR_TAB === character ||
|
||||
CHAR_LINE_FEED === character ||
|
||||
CHAR_CARRIAGE_RETURN === character ||
|
||||
CHAR_COMMA === character ||
|
||||
CHAR_LEFT_SQUARE_BRACKET === character ||
|
||||
CHAR_RIGHT_SQUARE_BRACKET === character ||
|
||||
CHAR_LEFT_CURLY_BRACKET === character ||
|
||||
CHAR_RIGHT_CURLY_BRACKET === character ||
|
||||
CHAR_SHARP === character ||
|
||||
CHAR_AMPERSAND === character ||
|
||||
CHAR_ASTERISK === character ||
|
||||
CHAR_EXCLAMATION === character ||
|
||||
CHAR_VERTICAL_LINE === character ||
|
||||
CHAR_GREATER_THAN === character ||
|
||||
CHAR_SINGLE_QUOTE === character ||
|
||||
CHAR_DOUBLE_QUOTE === character ||
|
||||
CHAR_PERCENT === character ||
|
||||
CHAR_COMMERCIAL_AT === character ||
|
||||
CHAR_COLON === character ||
|
||||
CHAR_GRAVE_ACCENT === character) {
|
||||
isQuoted = true;
|
||||
StringBuilder.prototype.escapeChar = function () {
|
||||
var character, esc;
|
||||
|
||||
character = this.source.charCodeAt(this.checkpoint);
|
||||
esc = ESCAPE_SEQUENCES[character] || encodeHex(character);
|
||||
this.result += esc;
|
||||
this.checkpoint += 1;
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
StringBuilder.prototype.finish = function () {
|
||||
if (this.source.length > this.checkpoint) {
|
||||
this.takeUpTo(this.source.length);
|
||||
}
|
||||
};
|
||||
|
||||
function writeScalar(state, object, level) {
|
||||
var simple, first, spaceWrap, folded, literal, single, double,
|
||||
sawLineFeed, linePosition, longestLine, indent, max, character,
|
||||
position, escapeSeq, hexEsc, previous, lineLength, modifier,
|
||||
trailingLineBreaks, result;
|
||||
|
||||
if (0 === object.length) {
|
||||
state.dump = "''";
|
||||
return;
|
||||
}
|
||||
|
||||
if (-1 !== DEPRECATED_BOOLEANS_SYNTAX.indexOf(object)) {
|
||||
state.dump = "'" + object + "'";
|
||||
return;
|
||||
}
|
||||
|
||||
simple = true;
|
||||
first = object.length ? object.charCodeAt(0) : 0;
|
||||
spaceWrap = (CHAR_SPACE === first ||
|
||||
CHAR_SPACE === object.charCodeAt(object.length - 1));
|
||||
|
||||
// Simplified check for restricted first characters
|
||||
// http://www.yaml.org/spec/1.2/spec.html#ns-plain-first%28c%29
|
||||
if (CHAR_MINUS === first ||
|
||||
CHAR_QUESTION === first ||
|
||||
CHAR_COMMERCIAL_AT === first ||
|
||||
CHAR_GRAVE_ACCENT === first) {
|
||||
simple = false;
|
||||
}
|
||||
|
||||
// can only use > and | if not wrapped in spaces.
|
||||
if (spaceWrap) {
|
||||
simple = false;
|
||||
folded = false;
|
||||
literal = false;
|
||||
} else {
|
||||
folded = true;
|
||||
literal = true;
|
||||
}
|
||||
|
||||
single = true;
|
||||
double = new StringBuilder(object);
|
||||
|
||||
sawLineFeed = false;
|
||||
linePosition = 0;
|
||||
longestLine = 0;
|
||||
|
||||
indent = state.indent * level;
|
||||
max = 80;
|
||||
if (indent < 40) {
|
||||
max -= indent;
|
||||
} else {
|
||||
max = 40;
|
||||
}
|
||||
|
||||
for (position = 0; position < object.length; position++) {
|
||||
character = object.charCodeAt(position);
|
||||
if (simple) {
|
||||
// Characters that can never appear in the simple scalar
|
||||
if (!simpleChar(character)) {
|
||||
simple = false;
|
||||
} else {
|
||||
// Still simple. If we make it all the way through like
|
||||
// this, then we can just dump the string as-is.
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (ESCAPE_SEQUENCES[character] ||
|
||||
!((0x00020 <= character && character <= 0x00007E) ||
|
||||
(0x00085 === character) ||
|
||||
(0x000A0 <= character && character <= 0x00D7FF) ||
|
||||
(0x0E000 <= character && character <= 0x00FFFD) ||
|
||||
(0x10000 <= character && character <= 0x10FFFF))) {
|
||||
state.dump += object.slice(checkpoint, position);
|
||||
state.dump += ESCAPE_SEQUENCES[character] || encodeHex(character);
|
||||
checkpoint = position + 1;
|
||||
isQuoted = true;
|
||||
if (single && character === CHAR_SINGLE_QUOTE) {
|
||||
single = false;
|
||||
}
|
||||
|
||||
escapeSeq = ESCAPE_SEQUENCES[character];
|
||||
hexEsc = needsHexEscape(character);
|
||||
|
||||
if (!escapeSeq && !hexEsc) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (character !== CHAR_LINE_FEED &&
|
||||
character !== CHAR_DOUBLE_QUOTE &&
|
||||
character !== CHAR_SINGLE_QUOTE) {
|
||||
folded = false;
|
||||
literal = false;
|
||||
} else if (character === CHAR_LINE_FEED) {
|
||||
sawLineFeed = true;
|
||||
single = false;
|
||||
if (position > 0) {
|
||||
previous = object.charCodeAt(position - 1);
|
||||
if (previous === CHAR_SPACE) {
|
||||
literal = false;
|
||||
folded = false;
|
||||
}
|
||||
}
|
||||
if (folded) {
|
||||
lineLength = position - linePosition;
|
||||
linePosition = position;
|
||||
if (lineLength > longestLine) {
|
||||
longestLine = lineLength;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (character !== CHAR_DOUBLE_QUOTE) {
|
||||
single = false;
|
||||
}
|
||||
|
||||
double.takeUpTo(position);
|
||||
double.escapeChar();
|
||||
}
|
||||
|
||||
if (simple && testImplicitResolving(state, object)) {
|
||||
simple = false;
|
||||
}
|
||||
|
||||
modifier = '';
|
||||
if (folded || literal) {
|
||||
trailingLineBreaks = 0;
|
||||
if (object.charCodeAt(object.length - 1) === CHAR_LINE_FEED) {
|
||||
trailingLineBreaks += 1;
|
||||
if (object.charCodeAt(object.length - 2) === CHAR_LINE_FEED) {
|
||||
trailingLineBreaks += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (trailingLineBreaks === 0) {
|
||||
modifier = '-';
|
||||
} else if (trailingLineBreaks === 2) {
|
||||
modifier = '+';
|
||||
}
|
||||
}
|
||||
|
||||
if (checkpoint < position) {
|
||||
state.dump += object.slice(checkpoint, position);
|
||||
if (literal && longestLine < max) {
|
||||
folded = false;
|
||||
}
|
||||
|
||||
if (!isQuoted && testImplicitResolving(state, state.dump)) {
|
||||
isQuoted = true;
|
||||
// If it's literally one line, then don't bother with the literal.
|
||||
// We may still want to do a fold, though, if it's a super long line.
|
||||
if (!sawLineFeed) {
|
||||
literal = false;
|
||||
}
|
||||
|
||||
if (isQuoted) {
|
||||
state.dump = '"' + state.dump + '"';
|
||||
if (simple) {
|
||||
state.dump = object;
|
||||
} else if (single) {
|
||||
state.dump = '\'' + object + '\'';
|
||||
} else if (folded) {
|
||||
result = fold(object, max);
|
||||
state.dump = '>' + modifier + '\n' + indentString(result, indent);
|
||||
} else if (literal) {
|
||||
if (!modifier) {
|
||||
object = object.replace(/\n$/, '');
|
||||
}
|
||||
state.dump = '|' + modifier + '\n' + indentString(object, indent);
|
||||
} else if (double) {
|
||||
double.finish();
|
||||
state.dump = '"' + double.result + '"';
|
||||
} else {
|
||||
throw new Error('Failed to dump scalar value');
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// The `trailing` var is a regexp match of any trailing `\n` characters.
|
||||
//
|
||||
// There are three cases we care about:
|
||||
//
|
||||
// 1. One trailing `\n` on the string. Just use `|` or `>`.
|
||||
// This is the assumed default. (trailing = null)
|
||||
// 2. No trailing `\n` on the string. Use `|-` or `>-` to "chomp" the end.
|
||||
// 3. More than one trailing `\n` on the string. Use `|+` or `>+`.
|
||||
//
|
||||
// In the case of `>+`, these line breaks are *not* doubled (like the line
|
||||
// breaks within the string), so it's important to only end with the exact
|
||||
// same number as we started.
|
||||
function fold(object, max) {
|
||||
var result = '',
|
||||
position = 0,
|
||||
length = object.length,
|
||||
trailing = /\n+$/.exec(object),
|
||||
newLine;
|
||||
|
||||
if (trailing) {
|
||||
length = trailing.index + 1;
|
||||
}
|
||||
|
||||
while (position < length) {
|
||||
newLine = object.indexOf('\n', position);
|
||||
if (newLine > length || newLine === -1) {
|
||||
if (result) {
|
||||
result += '\n\n';
|
||||
}
|
||||
result += foldLine(object.slice(position, length), max);
|
||||
position = length;
|
||||
} else {
|
||||
if (result) {
|
||||
result += '\n\n';
|
||||
}
|
||||
result += foldLine(object.slice(position, newLine), max);
|
||||
position = newLine + 1;
|
||||
}
|
||||
}
|
||||
if (trailing && trailing[0] !== '\n') {
|
||||
result += trailing[0];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function foldLine(line, max) {
|
||||
if (line === '') {
|
||||
return line;
|
||||
}
|
||||
|
||||
var foldRe = /[^\s] [^\s]/g,
|
||||
result = '',
|
||||
prevMatch = 0,
|
||||
foldStart = 0,
|
||||
match = foldRe.exec(line),
|
||||
index,
|
||||
foldEnd,
|
||||
folded;
|
||||
|
||||
while (match) {
|
||||
index = match.index;
|
||||
|
||||
// when we cross the max len, if the previous match would've
|
||||
// been ok, use that one, and carry on. If there was no previous
|
||||
// match on this fold section, then just have a long line.
|
||||
if (index - foldStart > max) {
|
||||
if (prevMatch !== foldStart) {
|
||||
foldEnd = prevMatch;
|
||||
} else {
|
||||
foldEnd = index;
|
||||
}
|
||||
|
||||
if (result) {
|
||||
result += '\n';
|
||||
}
|
||||
folded = line.slice(foldStart, foldEnd);
|
||||
result += folded;
|
||||
foldStart = foldEnd + 1;
|
||||
}
|
||||
prevMatch = index + 1;
|
||||
match = foldRe.exec(line);
|
||||
}
|
||||
|
||||
if (result) {
|
||||
result += '\n';
|
||||
}
|
||||
|
||||
// if we end up with one last word at the end, then the last bit might
|
||||
// be slightly bigger than we wanted, because we exited out of the loop.
|
||||
if (foldStart !== prevMatch && line.length - foldStart > max) {
|
||||
result += line.slice(foldStart, prevMatch) + '\n' +
|
||||
line.slice(prevMatch + 1);
|
||||
} else {
|
||||
result += line.slice(foldStart);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Returns true if character can be found in a simple scalar
|
||||
function simpleChar(character) {
|
||||
return CHAR_TAB !== character &&
|
||||
CHAR_LINE_FEED !== character &&
|
||||
CHAR_CARRIAGE_RETURN !== character &&
|
||||
CHAR_COMMA !== character &&
|
||||
CHAR_LEFT_SQUARE_BRACKET !== character &&
|
||||
CHAR_RIGHT_SQUARE_BRACKET !== character &&
|
||||
CHAR_LEFT_CURLY_BRACKET !== character &&
|
||||
CHAR_RIGHT_CURLY_BRACKET !== character &&
|
||||
CHAR_SHARP !== character &&
|
||||
CHAR_AMPERSAND !== character &&
|
||||
CHAR_ASTERISK !== character &&
|
||||
CHAR_EXCLAMATION !== character &&
|
||||
CHAR_VERTICAL_LINE !== character &&
|
||||
CHAR_GREATER_THAN !== character &&
|
||||
CHAR_SINGLE_QUOTE !== character &&
|
||||
CHAR_DOUBLE_QUOTE !== character &&
|
||||
CHAR_PERCENT !== character &&
|
||||
CHAR_COLON !== character &&
|
||||
!ESCAPE_SEQUENCES[character] &&
|
||||
!needsHexEscape(character);
|
||||
}
|
||||
|
||||
// Returns true if the character code needs to be escaped.
|
||||
function needsHexEscape(character) {
|
||||
return !((0x00020 <= character && character <= 0x00007E) ||
|
||||
(0x00085 === character) ||
|
||||
(0x000A0 <= character && character <= 0x00D7FF) ||
|
||||
(0x0E000 <= character && character <= 0x00FFFD) ||
|
||||
(0x10000 <= character && character <= 0x10FFFF));
|
||||
}
|
||||
|
||||
function writeFlowSequence(state, level, object) {
|
||||
|
@ -428,6 +705,18 @@ function writeBlockMapping(state, level, object, compact) {
|
|||
explicitPair,
|
||||
pairBuffer;
|
||||
|
||||
// Allow sorting keys so that the output file is deterministic
|
||||
if (state.sortKeys === true) {
|
||||
// Default sorting
|
||||
objectKeyList.sort();
|
||||
} else if (typeof state.sortKeys === 'function') {
|
||||
// Custom sort function
|
||||
objectKeyList.sort(state.sortKeys);
|
||||
} else if (state.sortKeys) {
|
||||
// Something is wrong
|
||||
throw new YAMLException('sortKeys must be a boolean or a function');
|
||||
}
|
||||
|
||||
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
||||
pairBuffer = '';
|
||||
|
||||
|
@ -576,11 +865,12 @@ function writeNode(state, level, object, block, compact) {
|
|||
}
|
||||
} else if ('[object String]' === type) {
|
||||
if ('?' !== state.tag) {
|
||||
writeScalar(state, state.dump);
|
||||
writeScalar(state, state.dump, level);
|
||||
}
|
||||
} else if (state.skipInvalid) {
|
||||
return false;
|
||||
} else {
|
||||
if (state.skipInvalid) {
|
||||
return false;
|
||||
}
|
||||
throw new YAMLException('unacceptable kind of an object to dump ' + type);
|
||||
}
|
||||
|
||||
|
@ -620,8 +910,8 @@ function inspectNode(object, objects, duplicatesIndexes) {
|
|||
}
|
||||
} else {
|
||||
objects.push(object);
|
||||
|
||||
if(Array.isArray(object)) {
|
||||
|
||||
if (Array.isArray(object)) {
|
||||
for (index = 0, length = object.length; index < length; index += 1) {
|
||||
inspectNode(object[index], objects, duplicatesIndexes);
|
||||
}
|
||||
|
@ -645,17 +935,14 @@ function dump(input, options) {
|
|||
|
||||
if (writeNode(state, 0, input, true, true)) {
|
||||
return state.dump + '\n';
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
function safeDump(input, options) {
|
||||
return dump(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
|
||||
}
|
||||
|
||||
|
||||
module.exports.dump = dump;
|
||||
module.exports.safeDump = safeDump;
|
||||
|
||||
|
@ -689,6 +976,7 @@ module.exports = YAMLException;
|
|||
},{}],5:[function(require,module,exports){
|
||||
'use strict';
|
||||
|
||||
/*eslint-disable max-len,no-use-before-define*/
|
||||
|
||||
var common = require('./common');
|
||||
var YAMLException = require('./exception');
|
||||
|
@ -711,7 +999,7 @@ var CHOMPING_STRIP = 2;
|
|||
var CHOMPING_KEEP = 3;
|
||||
|
||||
|
||||
var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uD800-\uDFFF\uFFFE\uFFFF]/;
|
||||
var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
||||
var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
|
||||
var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
|
||||
var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
|
||||
|
@ -748,7 +1036,9 @@ function fromHexCode(c) {
|
|||
return c - 0x30;
|
||||
}
|
||||
|
||||
/*eslint-disable no-bitwise*/
|
||||
lc = c | 0x20;
|
||||
|
||||
if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) {
|
||||
return lc - 0x61 + 10;
|
||||
}
|
||||
|
@ -772,7 +1062,7 @@ function fromDecimalCode(c) {
|
|||
}
|
||||
|
||||
function simpleEscapeSequence(c) {
|
||||
return (c === 0x30/* 0 */) ? '\x00' :
|
||||
return (c === 0x30/* 0 */) ? '\x00' :
|
||||
(c === 0x61/* a */) ? '\x07' :
|
||||
(c === 0x62/* b */) ? '\x08' :
|
||||
(c === 0x74/* t */) ? '\x09' :
|
||||
|
@ -795,12 +1085,11 @@ function simpleEscapeSequence(c) {
|
|||
function charFromCodepoint(c) {
|
||||
if (c <= 0xFFFF) {
|
||||
return String.fromCharCode(c);
|
||||
} else {
|
||||
// Encode UTF-16 surrogate pair
|
||||
// https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF
|
||||
return String.fromCharCode(((c - 0x010000) >> 10) + 0xD800,
|
||||
((c - 0x010000) & 0x03FF) + 0xDC00);
|
||||
}
|
||||
// Encode UTF-16 surrogate pair
|
||||
// https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF
|
||||
return String.fromCharCode(((c - 0x010000) >> 10) + 0xD800,
|
||||
((c - 0x010000) & 0x03FF) + 0xDC00);
|
||||
}
|
||||
|
||||
var simpleEscapeCheck = new Array(256); // integer, for fast access
|
||||
|
@ -866,7 +1155,7 @@ function throwWarning(state, message) {
|
|||
|
||||
var directiveHandlers = {
|
||||
|
||||
'YAML': function handleYamlDirective(state, name, args) {
|
||||
YAML: function handleYamlDirective(state, name, args) {
|
||||
|
||||
var match, major, minor;
|
||||
|
||||
|
@ -899,7 +1188,7 @@ var directiveHandlers = {
|
|||
}
|
||||
},
|
||||
|
||||
'TAG': function handleTagDirective(state, name, args) {
|
||||
TAG: function handleTagDirective(state, name, args) {
|
||||
|
||||
var handle, prefix;
|
||||
|
||||
|
@ -1059,7 +1348,7 @@ function testDocumentSeparator(state) {
|
|||
// in parent on each call, for efficiency. No needs to test here again.
|
||||
if ((0x2D/* - */ === ch || 0x2E/* . */ === ch) &&
|
||||
state.input.charCodeAt(_position + 1) === ch &&
|
||||
state.input.charCodeAt(_position+ 2) === ch) {
|
||||
state.input.charCodeAt(_position + 2) === ch) {
|
||||
|
||||
_position += 3;
|
||||
|
||||
|
@ -1129,7 +1418,7 @@ function readPlainScalar(state, nodeIndent, withinFlowCollection) {
|
|||
|
||||
while (0 !== ch) {
|
||||
if (0x3A/* : */ === ch) {
|
||||
following = state.input.charCodeAt(state.position+1);
|
||||
following = state.input.charCodeAt(state.position + 1);
|
||||
|
||||
if (is_WS_OR_EOL(following) ||
|
||||
withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
||||
|
@ -1184,11 +1473,11 @@ function readPlainScalar(state, nodeIndent, withinFlowCollection) {
|
|||
|
||||
if (state.result) {
|
||||
return true;
|
||||
} else {
|
||||
state.kind = _kind;
|
||||
state.result = _result;
|
||||
return false;
|
||||
}
|
||||
|
||||
state.kind = _kind;
|
||||
state.result = _result;
|
||||
return false;
|
||||
}
|
||||
|
||||
function readSingleQuotedScalar(state, nodeIndent) {
|
||||
|
@ -1267,7 +1556,7 @@ function readDoubleQuotedScalar(state, nodeIndent) {
|
|||
if (is_EOL(ch)) {
|
||||
skipSeparationSpace(state, false, nodeIndent);
|
||||
|
||||
//TODO: rework to inline fn with no type cast?
|
||||
// TODO: rework to inline fn with no type cast?
|
||||
} else if (ch < 256 && simpleEscapeCheck[ch]) {
|
||||
state.result += simpleEscapeMap[ch];
|
||||
state.position++;
|
||||
|
@ -1333,11 +1622,11 @@ function readFlowCollection(state, nodeIndent) {
|
|||
ch = state.input.charCodeAt(state.position);
|
||||
|
||||
if (ch === 0x5B/* [ */) {
|
||||
terminator = 0x5D/* ] */;
|
||||
terminator = 0x5D;/* ] */
|
||||
isMapping = false;
|
||||
_result = [];
|
||||
} else if (ch === 0x7B/* { */) {
|
||||
terminator = 0x7D/* } */;
|
||||
terminator = 0x7D;/* } */
|
||||
isMapping = true;
|
||||
_result = {};
|
||||
} else {
|
||||
|
@ -1539,24 +1828,20 @@ function readBlockScalar(state, nodeIndent) {
|
|||
}
|
||||
|
||||
// Literal style: just add exact number of line breaks between content lines.
|
||||
} else {
|
||||
|
||||
} else if (detectedIndent) {
|
||||
// If current line isn't the first one - count line break from the last content line.
|
||||
if (detectedIndent) {
|
||||
state.result += common.repeat('\n', emptyLines + 1);
|
||||
|
||||
state.result += common.repeat('\n', emptyLines + 1);
|
||||
} else {
|
||||
// In case of the first content line - count only empty lines.
|
||||
} else {
|
||||
state.result += common.repeat('\n', emptyLines);
|
||||
}
|
||||
}
|
||||
|
||||
detectedIndent = true;
|
||||
emptyLines = 0;
|
||||
captureStart = state.position;
|
||||
|
||||
while (!is_EOL(ch) && (0 !== ch))
|
||||
{ ch = state.input.charCodeAt(++state.position); }
|
||||
while (!is_EOL(ch) && (0 !== ch)) {
|
||||
ch = state.input.charCodeAt(++state.position);
|
||||
}
|
||||
|
||||
captureSegment(state, captureStart, state.position, false);
|
||||
}
|
||||
|
@ -1622,9 +1907,8 @@ function readBlockSequence(state, nodeIndent) {
|
|||
state.kind = 'sequence';
|
||||
state.result = _result;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function readBlockMapping(state, nodeIndent, flowIndent) {
|
||||
|
@ -2204,10 +2488,18 @@ function loadDocuments(input, options) {
|
|||
input = String(input);
|
||||
options = options || {};
|
||||
|
||||
if (0 !== input.length &&
|
||||
0x0A/* LF */ !== input.charCodeAt(input.length - 1) &&
|
||||
0x0D/* CR */ !== input.charCodeAt(input.length - 1)) {
|
||||
input += '\n';
|
||||
if (input.length !== 0) {
|
||||
|
||||
// Add tailing `\n` if not exists
|
||||
if (0x0A/* LF */ !== input.charCodeAt(input.length - 1) &&
|
||||
0x0D/* CR */ !== input.charCodeAt(input.length - 1)) {
|
||||
input += '\n';
|
||||
}
|
||||
|
||||
// Strip BOM
|
||||
if (input.charCodeAt(0) === 0xFEFF) {
|
||||
input = input.slice(1);
|
||||
}
|
||||
}
|
||||
|
||||
var state = new State(input, options);
|
||||
|
@ -2245,12 +2537,12 @@ function load(input, options) {
|
|||
var documents = loadDocuments(input, options), index, length;
|
||||
|
||||
if (0 === documents.length) {
|
||||
/*eslint-disable no-undefined*/
|
||||
return undefined;
|
||||
} else if (1 === documents.length) {
|
||||
return documents[0];
|
||||
} else {
|
||||
throw new YAMLException('expected a single document in the stream, but found more');
|
||||
}
|
||||
throw new YAMLException('expected a single document in the stream, but found more');
|
||||
}
|
||||
|
||||
|
||||
|
@ -2352,6 +2644,7 @@ module.exports = Mark;
|
|||
},{"./common":2}],7:[function(require,module,exports){
|
||||
'use strict';
|
||||
|
||||
/*eslint-disable max-len*/
|
||||
|
||||
var common = require('./common');
|
||||
var YAMLException = require('./exception');
|
||||
|
@ -2643,6 +2936,7 @@ module.exports = Type;
|
|||
},{"./exception":4}],14:[function(require,module,exports){
|
||||
'use strict';
|
||||
|
||||
/*eslint-disable no-bitwise*/
|
||||
|
||||
// A trick for browserified version.
|
||||
// Since we make browserifier to ignore `buffer` module, NodeBuffer will be undefined
|
||||
|
@ -2662,7 +2956,7 @@ function resolveYamlBinary(data) {
|
|||
var code, idx, bitlen = 0, len = 0, max = data.length, map = BASE64_MAP;
|
||||
|
||||
// Convert one by one.
|
||||
for (idx = 0; idx < max; idx ++) {
|
||||
for (idx = 0; idx < max; idx++) {
|
||||
code = map.indexOf(data.charAt(idx));
|
||||
|
||||
// Skip CR/LF
|
||||
|
@ -2700,7 +2994,7 @@ function constructYamlBinary(data) {
|
|||
|
||||
// Dump tail
|
||||
|
||||
tailbits = (max % 4)*6;
|
||||
tailbits = (max % 4) * 6;
|
||||
|
||||
if (tailbits === 0) {
|
||||
result.push((bits >> 16) & 0xFF);
|
||||
|
@ -2872,9 +3166,8 @@ function constructYamlFloat(data) {
|
|||
|
||||
return sign * value;
|
||||
|
||||
} else {
|
||||
return sign * parseFloat(value, 10);
|
||||
}
|
||||
return sign * parseFloat(value, 10);
|
||||
}
|
||||
|
||||
function representYamlFloat(object, style) {
|
||||
|
@ -2907,9 +3200,8 @@ function representYamlFloat(object, style) {
|
|||
}
|
||||
} else if (common.isNegativeZero(object)) {
|
||||
return '-0.0';
|
||||
} else {
|
||||
return object.toString(10);
|
||||
}
|
||||
return object.toString(10);
|
||||
}
|
||||
|
||||
function isFloat(object) {
|
||||
|
@ -2967,7 +3259,7 @@ function resolveYamlInteger(data) {
|
|||
|
||||
if (ch === '0') {
|
||||
// 0
|
||||
if (index+1 === max) { return true; }
|
||||
if (index + 1 === max) { return true; }
|
||||
ch = data[++index];
|
||||
|
||||
// base 2, base 8, base 16
|
||||
|
@ -3179,7 +3471,8 @@ function constructJavascriptFunction(data) {
|
|||
|
||||
// Esprima's ranges include the first '{' and the last '}' characters on
|
||||
// function expressions. So cut them out.
|
||||
return new Function(params, source.slice(body[0]+1, body[1]-1));
|
||||
/*eslint-disable no-new-func*/
|
||||
return new Function(params, source.slice(body[0] + 1, body[1] - 1));
|
||||
}
|
||||
|
||||
function representJavascriptFunction(object /*, style*/) {
|
||||
|
@ -3294,6 +3587,7 @@ function resolveJavascriptUndefined() {
|
|||
}
|
||||
|
||||
function constructJavascriptUndefined() {
|
||||
/*eslint-disable no-undefined*/
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
/*eslint-disable no-console*/
|
||||
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
|
@ -78,23 +79,23 @@ var SpaceYamlType = new yaml.Type('!space', {
|
|||
|
||||
var SPACE_SCHEMA = yaml.Schema.create([ SpaceYamlType, PointYamlType ]);
|
||||
|
||||
// do not execute the following if file is required (http://stackoverflow.com/a/6398335)
|
||||
if (require.main === module) {
|
||||
|
||||
// And read a document using that schema.
|
||||
|
||||
fs.readFile(path.join(__dirname, 'custom_types.yml'), 'utf8', function (error, data) {
|
||||
var loaded;
|
||||
|
||||
if (!error) {
|
||||
loaded = yaml.load(data, { schema: SPACE_SCHEMA });
|
||||
console.log(util.inspect(loaded, false, 20, true));
|
||||
} else {
|
||||
console.error(error.stack || error.message || String(error));
|
||||
}
|
||||
});
|
||||
// And read a document using that schema.
|
||||
fs.readFile(path.join(__dirname, 'custom_types.yml'), 'utf8', function (error, data) {
|
||||
var loaded;
|
||||
|
||||
if (!error) {
|
||||
loaded = yaml.load(data, { schema: SPACE_SCHEMA });
|
||||
console.log(util.inspect(loaded, false, 20, true));
|
||||
} else {
|
||||
console.error(error.stack || error.message || String(error));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// There are some exports to play with this example interactively.
|
||||
|
||||
module.exports.Point = Point;
|
||||
module.exports.Space = Space;
|
||||
module.exports.PointYamlType = PointYamlType;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
/*eslint-disable no-console*/
|
||||
|
||||
var yaml = require('../lib/js-yaml');
|
||||
var object = require('./dumper.json');
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
/*eslint-disable no-console*/
|
||||
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
|
||||
function isNothing(subject) {
|
||||
return (undefined === subject) || (null === subject);
|
||||
return (typeof subject === 'undefined') || (null === subject);
|
||||
}
|
||||
|
||||
|
||||
function isObject(subject) {
|
||||
return ('object' === typeof subject) && (null !== subject);
|
||||
return (typeof subject === 'object') && (null !== subject);
|
||||
}
|
||||
|
||||
|
||||
|
@ -16,9 +16,8 @@ function toArray(sequence) {
|
|||
return sequence;
|
||||
} else if (isNothing(sequence)) {
|
||||
return [];
|
||||
} else {
|
||||
return [ sequence ];
|
||||
}
|
||||
return [ sequence ];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
'use strict';
|
||||
|
||||
/*eslint-disable no-use-before-define*/
|
||||
|
||||
var common = require('./common');
|
||||
var YAMLException = require('./exception');
|
||||
var DEFAULT_FULL_SCHEMA = require('./schema/default_full');
|
||||
var DEFAULT_SAFE_SCHEMA = require('./schema/default_safe');
|
||||
|
||||
|
||||
var _toString = Object.prototype.toString;
|
||||
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
|
||||
|
||||
var CHAR_TAB = 0x09; /* Tab */
|
||||
var CHAR_LINE_FEED = 0x0A; /* LF */
|
||||
var CHAR_CARRIAGE_RETURN = 0x0D; /* CR */
|
||||
|
@ -35,7 +34,6 @@ var CHAR_LEFT_CURLY_BRACKET = 0x7B; /* { */
|
|||
var CHAR_VERTICAL_LINE = 0x7C; /* | */
|
||||
var CHAR_RIGHT_CURLY_BRACKET = 0x7D; /* } */
|
||||
|
||||
|
||||
var ESCAPE_SEQUENCES = {};
|
||||
|
||||
ESCAPE_SEQUENCES[0x00] = '\\0';
|
||||
|
@ -54,13 +52,11 @@ ESCAPE_SEQUENCES[0xA0] = '\\_';
|
|||
ESCAPE_SEQUENCES[0x2028] = '\\L';
|
||||
ESCAPE_SEQUENCES[0x2029] = '\\P';
|
||||
|
||||
|
||||
var DEPRECATED_BOOLEANS_SYNTAX = [
|
||||
'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON',
|
||||
'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF'
|
||||
];
|
||||
|
||||
|
||||
function compileStyleMap(schema, map) {
|
||||
var result, keys, index, length, tag, style, type;
|
||||
|
||||
|
@ -91,7 +87,6 @@ function compileStyleMap(schema, map) {
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
function encodeHex(character) {
|
||||
var string, handle, length;
|
||||
|
||||
|
@ -113,13 +108,13 @@ function encodeHex(character) {
|
|||
return '\\' + handle + common.repeat('0', length - string.length) + string;
|
||||
}
|
||||
|
||||
|
||||
function State(options) {
|
||||
this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
|
||||
this.indent = Math.max(1, (options['indent'] || 2));
|
||||
this.skipInvalid = options['skipInvalid'] || false;
|
||||
this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']);
|
||||
this.styleMap = compileStyleMap(this.schema, options['styles'] || null);
|
||||
this.sortKeys = options['sortKeys'] || false;
|
||||
|
||||
this.implicitTypes = this.schema.compiledImplicit;
|
||||
this.explicitTypes = this.schema.compiledExplicit;
|
||||
|
@ -131,6 +126,31 @@ function State(options) {
|
|||
this.usedDuplicates = null;
|
||||
}
|
||||
|
||||
function indentString(string, spaces) {
|
||||
var ind = common.repeat(' ', spaces),
|
||||
position = 0,
|
||||
next = -1,
|
||||
result = '',
|
||||
line,
|
||||
length = string.length;
|
||||
|
||||
while (position < length) {
|
||||
next = string.indexOf('\n', position);
|
||||
if (next === -1) {
|
||||
line = string.slice(position);
|
||||
position = length;
|
||||
} else {
|
||||
line = string.slice(position, next + 1);
|
||||
position = next + 1;
|
||||
}
|
||||
if (line.length && line !== '\n') {
|
||||
result += ind;
|
||||
}
|
||||
result += line;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function generateNextLine(state, level) {
|
||||
return '\n' + common.repeat(' ', state.indent * level);
|
||||
|
@ -150,81 +170,339 @@ function testImplicitResolving(state, str) {
|
|||
return false;
|
||||
}
|
||||
|
||||
function writeScalar(state, object) {
|
||||
var isQuoted, checkpoint, position, length, character, first;
|
||||
function StringBuilder(source) {
|
||||
this.source = source;
|
||||
this.result = '';
|
||||
this.checkpoint = 0;
|
||||
}
|
||||
|
||||
state.dump = '';
|
||||
isQuoted = false;
|
||||
checkpoint = 0;
|
||||
first = object.charCodeAt(0) || 0;
|
||||
StringBuilder.prototype.takeUpTo = function (position) {
|
||||
var er;
|
||||
|
||||
if (-1 !== DEPRECATED_BOOLEANS_SYNTAX.indexOf(object)) {
|
||||
// Ensure compatibility with YAML 1.0/1.1 loaders.
|
||||
isQuoted = true;
|
||||
} else if (0 === object.length) {
|
||||
// Quote empty string
|
||||
isQuoted = true;
|
||||
} else if (CHAR_SPACE === first ||
|
||||
CHAR_SPACE === object.charCodeAt(object.length - 1)) {
|
||||
isQuoted = true;
|
||||
} else if (CHAR_MINUS === first ||
|
||||
CHAR_QUESTION === first) {
|
||||
// Don't check second symbol for simplicity
|
||||
isQuoted = true;
|
||||
if (position < this.checkpoint) {
|
||||
er = new Error('position should be > checkpoint');
|
||||
er.position = position;
|
||||
er.checkpoint = this.checkpoint;
|
||||
throw er;
|
||||
}
|
||||
|
||||
for (position = 0, length = object.length; position < length; position += 1) {
|
||||
character = object.charCodeAt(position);
|
||||
this.result += this.source.slice(this.checkpoint, position);
|
||||
this.checkpoint = position;
|
||||
return this;
|
||||
};
|
||||
|
||||
if (!isQuoted) {
|
||||
if (CHAR_TAB === character ||
|
||||
CHAR_LINE_FEED === character ||
|
||||
CHAR_CARRIAGE_RETURN === character ||
|
||||
CHAR_COMMA === character ||
|
||||
CHAR_LEFT_SQUARE_BRACKET === character ||
|
||||
CHAR_RIGHT_SQUARE_BRACKET === character ||
|
||||
CHAR_LEFT_CURLY_BRACKET === character ||
|
||||
CHAR_RIGHT_CURLY_BRACKET === character ||
|
||||
CHAR_SHARP === character ||
|
||||
CHAR_AMPERSAND === character ||
|
||||
CHAR_ASTERISK === character ||
|
||||
CHAR_EXCLAMATION === character ||
|
||||
CHAR_VERTICAL_LINE === character ||
|
||||
CHAR_GREATER_THAN === character ||
|
||||
CHAR_SINGLE_QUOTE === character ||
|
||||
CHAR_DOUBLE_QUOTE === character ||
|
||||
CHAR_PERCENT === character ||
|
||||
CHAR_COMMERCIAL_AT === character ||
|
||||
CHAR_COLON === character ||
|
||||
CHAR_GRAVE_ACCENT === character) {
|
||||
isQuoted = true;
|
||||
StringBuilder.prototype.escapeChar = function () {
|
||||
var character, esc;
|
||||
|
||||
character = this.source.charCodeAt(this.checkpoint);
|
||||
esc = ESCAPE_SEQUENCES[character] || encodeHex(character);
|
||||
this.result += esc;
|
||||
this.checkpoint += 1;
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
StringBuilder.prototype.finish = function () {
|
||||
if (this.source.length > this.checkpoint) {
|
||||
this.takeUpTo(this.source.length);
|
||||
}
|
||||
};
|
||||
|
||||
function writeScalar(state, object, level) {
|
||||
var simple, first, spaceWrap, folded, literal, single, double,
|
||||
sawLineFeed, linePosition, longestLine, indent, max, character,
|
||||
position, escapeSeq, hexEsc, previous, lineLength, modifier,
|
||||
trailingLineBreaks, result;
|
||||
|
||||
if (0 === object.length) {
|
||||
state.dump = "''";
|
||||
return;
|
||||
}
|
||||
|
||||
if (-1 !== DEPRECATED_BOOLEANS_SYNTAX.indexOf(object)) {
|
||||
state.dump = "'" + object + "'";
|
||||
return;
|
||||
}
|
||||
|
||||
simple = true;
|
||||
first = object.length ? object.charCodeAt(0) : 0;
|
||||
spaceWrap = (CHAR_SPACE === first ||
|
||||
CHAR_SPACE === object.charCodeAt(object.length - 1));
|
||||
|
||||
// Simplified check for restricted first characters
|
||||
// http://www.yaml.org/spec/1.2/spec.html#ns-plain-first%28c%29
|
||||
if (CHAR_MINUS === first ||
|
||||
CHAR_QUESTION === first ||
|
||||
CHAR_COMMERCIAL_AT === first ||
|
||||
CHAR_GRAVE_ACCENT === first) {
|
||||
simple = false;
|
||||
}
|
||||
|
||||
// can only use > and | if not wrapped in spaces.
|
||||
if (spaceWrap) {
|
||||
simple = false;
|
||||
folded = false;
|
||||
literal = false;
|
||||
} else {
|
||||
folded = true;
|
||||
literal = true;
|
||||
}
|
||||
|
||||
single = true;
|
||||
double = new StringBuilder(object);
|
||||
|
||||
sawLineFeed = false;
|
||||
linePosition = 0;
|
||||
longestLine = 0;
|
||||
|
||||
indent = state.indent * level;
|
||||
max = 80;
|
||||
if (indent < 40) {
|
||||
max -= indent;
|
||||
} else {
|
||||
max = 40;
|
||||
}
|
||||
|
||||
for (position = 0; position < object.length; position++) {
|
||||
character = object.charCodeAt(position);
|
||||
if (simple) {
|
||||
// Characters that can never appear in the simple scalar
|
||||
if (!simpleChar(character)) {
|
||||
simple = false;
|
||||
} else {
|
||||
// Still simple. If we make it all the way through like
|
||||
// this, then we can just dump the string as-is.
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (ESCAPE_SEQUENCES[character] ||
|
||||
!((0x00020 <= character && character <= 0x00007E) ||
|
||||
(0x00085 === character) ||
|
||||
(0x000A0 <= character && character <= 0x00D7FF) ||
|
||||
(0x0E000 <= character && character <= 0x00FFFD) ||
|
||||
(0x10000 <= character && character <= 0x10FFFF))) {
|
||||
state.dump += object.slice(checkpoint, position);
|
||||
state.dump += ESCAPE_SEQUENCES[character] || encodeHex(character);
|
||||
checkpoint = position + 1;
|
||||
isQuoted = true;
|
||||
if (single && character === CHAR_SINGLE_QUOTE) {
|
||||
single = false;
|
||||
}
|
||||
|
||||
escapeSeq = ESCAPE_SEQUENCES[character];
|
||||
hexEsc = needsHexEscape(character);
|
||||
|
||||
if (!escapeSeq && !hexEsc) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (character !== CHAR_LINE_FEED &&
|
||||
character !== CHAR_DOUBLE_QUOTE &&
|
||||
character !== CHAR_SINGLE_QUOTE) {
|
||||
folded = false;
|
||||
literal = false;
|
||||
} else if (character === CHAR_LINE_FEED) {
|
||||
sawLineFeed = true;
|
||||
single = false;
|
||||
if (position > 0) {
|
||||
previous = object.charCodeAt(position - 1);
|
||||
if (previous === CHAR_SPACE) {
|
||||
literal = false;
|
||||
folded = false;
|
||||
}
|
||||
}
|
||||
if (folded) {
|
||||
lineLength = position - linePosition;
|
||||
linePosition = position;
|
||||
if (lineLength > longestLine) {
|
||||
longestLine = lineLength;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (character !== CHAR_DOUBLE_QUOTE) {
|
||||
single = false;
|
||||
}
|
||||
|
||||
double.takeUpTo(position);
|
||||
double.escapeChar();
|
||||
}
|
||||
|
||||
if (simple && testImplicitResolving(state, object)) {
|
||||
simple = false;
|
||||
}
|
||||
|
||||
modifier = '';
|
||||
if (folded || literal) {
|
||||
trailingLineBreaks = 0;
|
||||
if (object.charCodeAt(object.length - 1) === CHAR_LINE_FEED) {
|
||||
trailingLineBreaks += 1;
|
||||
if (object.charCodeAt(object.length - 2) === CHAR_LINE_FEED) {
|
||||
trailingLineBreaks += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (trailingLineBreaks === 0) {
|
||||
modifier = '-';
|
||||
} else if (trailingLineBreaks === 2) {
|
||||
modifier = '+';
|
||||
}
|
||||
}
|
||||
|
||||
if (checkpoint < position) {
|
||||
state.dump += object.slice(checkpoint, position);
|
||||
if (literal && longestLine < max) {
|
||||
folded = false;
|
||||
}
|
||||
|
||||
if (!isQuoted && testImplicitResolving(state, state.dump)) {
|
||||
isQuoted = true;
|
||||
// If it's literally one line, then don't bother with the literal.
|
||||
// We may still want to do a fold, though, if it's a super long line.
|
||||
if (!sawLineFeed) {
|
||||
literal = false;
|
||||
}
|
||||
|
||||
if (isQuoted) {
|
||||
state.dump = '"' + state.dump + '"';
|
||||
if (simple) {
|
||||
state.dump = object;
|
||||
} else if (single) {
|
||||
state.dump = '\'' + object + '\'';
|
||||
} else if (folded) {
|
||||
result = fold(object, max);
|
||||
state.dump = '>' + modifier + '\n' + indentString(result, indent);
|
||||
} else if (literal) {
|
||||
if (!modifier) {
|
||||
object = object.replace(/\n$/, '');
|
||||
}
|
||||
state.dump = '|' + modifier + '\n' + indentString(object, indent);
|
||||
} else if (double) {
|
||||
double.finish();
|
||||
state.dump = '"' + double.result + '"';
|
||||
} else {
|
||||
throw new Error('Failed to dump scalar value');
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// The `trailing` var is a regexp match of any trailing `\n` characters.
|
||||
//
|
||||
// There are three cases we care about:
|
||||
//
|
||||
// 1. One trailing `\n` on the string. Just use `|` or `>`.
|
||||
// This is the assumed default. (trailing = null)
|
||||
// 2. No trailing `\n` on the string. Use `|-` or `>-` to "chomp" the end.
|
||||
// 3. More than one trailing `\n` on the string. Use `|+` or `>+`.
|
||||
//
|
||||
// In the case of `>+`, these line breaks are *not* doubled (like the line
|
||||
// breaks within the string), so it's important to only end with the exact
|
||||
// same number as we started.
|
||||
function fold(object, max) {
|
||||
var result = '',
|
||||
position = 0,
|
||||
length = object.length,
|
||||
trailing = /\n+$/.exec(object),
|
||||
newLine;
|
||||
|
||||
if (trailing) {
|
||||
length = trailing.index + 1;
|
||||
}
|
||||
|
||||
while (position < length) {
|
||||
newLine = object.indexOf('\n', position);
|
||||
if (newLine > length || newLine === -1) {
|
||||
if (result) {
|
||||
result += '\n\n';
|
||||
}
|
||||
result += foldLine(object.slice(position, length), max);
|
||||
position = length;
|
||||
} else {
|
||||
if (result) {
|
||||
result += '\n\n';
|
||||
}
|
||||
result += foldLine(object.slice(position, newLine), max);
|
||||
position = newLine + 1;
|
||||
}
|
||||
}
|
||||
if (trailing && trailing[0] !== '\n') {
|
||||
result += trailing[0];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function foldLine(line, max) {
|
||||
if (line === '') {
|
||||
return line;
|
||||
}
|
||||
|
||||
var foldRe = /[^\s] [^\s]/g,
|
||||
result = '',
|
||||
prevMatch = 0,
|
||||
foldStart = 0,
|
||||
match = foldRe.exec(line),
|
||||
index,
|
||||
foldEnd,
|
||||
folded;
|
||||
|
||||
while (match) {
|
||||
index = match.index;
|
||||
|
||||
// when we cross the max len, if the previous match would've
|
||||
// been ok, use that one, and carry on. If there was no previous
|
||||
// match on this fold section, then just have a long line.
|
||||
if (index - foldStart > max) {
|
||||
if (prevMatch !== foldStart) {
|
||||
foldEnd = prevMatch;
|
||||
} else {
|
||||
foldEnd = index;
|
||||
}
|
||||
|
||||
if (result) {
|
||||
result += '\n';
|
||||
}
|
||||
folded = line.slice(foldStart, foldEnd);
|
||||
result += folded;
|
||||
foldStart = foldEnd + 1;
|
||||
}
|
||||
prevMatch = index + 1;
|
||||
match = foldRe.exec(line);
|
||||
}
|
||||
|
||||
if (result) {
|
||||
result += '\n';
|
||||
}
|
||||
|
||||
// if we end up with one last word at the end, then the last bit might
|
||||
// be slightly bigger than we wanted, because we exited out of the loop.
|
||||
if (foldStart !== prevMatch && line.length - foldStart > max) {
|
||||
result += line.slice(foldStart, prevMatch) + '\n' +
|
||||
line.slice(prevMatch + 1);
|
||||
} else {
|
||||
result += line.slice(foldStart);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Returns true if character can be found in a simple scalar
|
||||
function simpleChar(character) {
|
||||
return CHAR_TAB !== character &&
|
||||
CHAR_LINE_FEED !== character &&
|
||||
CHAR_CARRIAGE_RETURN !== character &&
|
||||
CHAR_COMMA !== character &&
|
||||
CHAR_LEFT_SQUARE_BRACKET !== character &&
|
||||
CHAR_RIGHT_SQUARE_BRACKET !== character &&
|
||||
CHAR_LEFT_CURLY_BRACKET !== character &&
|
||||
CHAR_RIGHT_CURLY_BRACKET !== character &&
|
||||
CHAR_SHARP !== character &&
|
||||
CHAR_AMPERSAND !== character &&
|
||||
CHAR_ASTERISK !== character &&
|
||||
CHAR_EXCLAMATION !== character &&
|
||||
CHAR_VERTICAL_LINE !== character &&
|
||||
CHAR_GREATER_THAN !== character &&
|
||||
CHAR_SINGLE_QUOTE !== character &&
|
||||
CHAR_DOUBLE_QUOTE !== character &&
|
||||
CHAR_PERCENT !== character &&
|
||||
CHAR_COLON !== character &&
|
||||
!ESCAPE_SEQUENCES[character] &&
|
||||
!needsHexEscape(character);
|
||||
}
|
||||
|
||||
// Returns true if the character code needs to be escaped.
|
||||
function needsHexEscape(character) {
|
||||
return !((0x00020 <= character && character <= 0x00007E) ||
|
||||
(0x00085 === character) ||
|
||||
(0x000A0 <= character && character <= 0x00D7FF) ||
|
||||
(0x0E000 <= character && character <= 0x00FFFD) ||
|
||||
(0x10000 <= character && character <= 0x10FFFF));
|
||||
}
|
||||
|
||||
function writeFlowSequence(state, level, object) {
|
||||
|
@ -322,6 +600,18 @@ function writeBlockMapping(state, level, object, compact) {
|
|||
explicitPair,
|
||||
pairBuffer;
|
||||
|
||||
// Allow sorting keys so that the output file is deterministic
|
||||
if (state.sortKeys === true) {
|
||||
// Default sorting
|
||||
objectKeyList.sort();
|
||||
} else if (typeof state.sortKeys === 'function') {
|
||||
// Custom sort function
|
||||
objectKeyList.sort(state.sortKeys);
|
||||
} else if (state.sortKeys) {
|
||||
// Something is wrong
|
||||
throw new YAMLException('sortKeys must be a boolean or a function');
|
||||
}
|
||||
|
||||
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
||||
pairBuffer = '';
|
||||
|
||||
|
@ -470,11 +760,12 @@ function writeNode(state, level, object, block, compact) {
|
|||
}
|
||||
} else if ('[object String]' === type) {
|
||||
if ('?' !== state.tag) {
|
||||
writeScalar(state, state.dump);
|
||||
writeScalar(state, state.dump, level);
|
||||
}
|
||||
} else if (state.skipInvalid) {
|
||||
return false;
|
||||
} else {
|
||||
if (state.skipInvalid) {
|
||||
return false;
|
||||
}
|
||||
throw new YAMLException('unacceptable kind of an object to dump ' + type);
|
||||
}
|
||||
|
||||
|
@ -514,8 +805,8 @@ function inspectNode(object, objects, duplicatesIndexes) {
|
|||
}
|
||||
} else {
|
||||
objects.push(object);
|
||||
|
||||
if(Array.isArray(object)) {
|
||||
|
||||
if (Array.isArray(object)) {
|
||||
for (index = 0, length = object.length; index < length; index += 1) {
|
||||
inspectNode(object[index], objects, duplicatesIndexes);
|
||||
}
|
||||
|
@ -539,16 +830,13 @@ function dump(input, options) {
|
|||
|
||||
if (writeNode(state, 0, input, true, true)) {
|
||||
return state.dump + '\n';
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
function safeDump(input, options) {
|
||||
return dump(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
|
||||
}
|
||||
|
||||
|
||||
module.exports.dump = dump;
|
||||
module.exports.safeDump = safeDump;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
/*eslint-disable max-len,no-use-before-define*/
|
||||
|
||||
var common = require('./common');
|
||||
var YAMLException = require('./exception');
|
||||
|
@ -22,7 +23,7 @@ var CHOMPING_STRIP = 2;
|
|||
var CHOMPING_KEEP = 3;
|
||||
|
||||
|
||||
var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uD800-\uDFFF\uFFFE\uFFFF]/;
|
||||
var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
||||
var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
|
||||
var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
|
||||
var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
|
||||
|
@ -59,7 +60,9 @@ function fromHexCode(c) {
|
|||
return c - 0x30;
|
||||
}
|
||||
|
||||
/*eslint-disable no-bitwise*/
|
||||
lc = c | 0x20;
|
||||
|
||||
if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) {
|
||||
return lc - 0x61 + 10;
|
||||
}
|
||||
|
@ -83,7 +86,7 @@ function fromDecimalCode(c) {
|
|||
}
|
||||
|
||||
function simpleEscapeSequence(c) {
|
||||
return (c === 0x30/* 0 */) ? '\x00' :
|
||||
return (c === 0x30/* 0 */) ? '\x00' :
|
||||
(c === 0x61/* a */) ? '\x07' :
|
||||
(c === 0x62/* b */) ? '\x08' :
|
||||
(c === 0x74/* t */) ? '\x09' :
|
||||
|
@ -106,12 +109,11 @@ function simpleEscapeSequence(c) {
|
|||
function charFromCodepoint(c) {
|
||||
if (c <= 0xFFFF) {
|
||||
return String.fromCharCode(c);
|
||||
} else {
|
||||
// Encode UTF-16 surrogate pair
|
||||
// https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF
|
||||
return String.fromCharCode(((c - 0x010000) >> 10) + 0xD800,
|
||||
((c - 0x010000) & 0x03FF) + 0xDC00);
|
||||
}
|
||||
// Encode UTF-16 surrogate pair
|
||||
// https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF
|
||||
return String.fromCharCode(((c - 0x010000) >> 10) + 0xD800,
|
||||
((c - 0x010000) & 0x03FF) + 0xDC00);
|
||||
}
|
||||
|
||||
var simpleEscapeCheck = new Array(256); // integer, for fast access
|
||||
|
@ -177,7 +179,7 @@ function throwWarning(state, message) {
|
|||
|
||||
var directiveHandlers = {
|
||||
|
||||
'YAML': function handleYamlDirective(state, name, args) {
|
||||
YAML: function handleYamlDirective(state, name, args) {
|
||||
|
||||
var match, major, minor;
|
||||
|
||||
|
@ -210,7 +212,7 @@ var directiveHandlers = {
|
|||
}
|
||||
},
|
||||
|
||||
'TAG': function handleTagDirective(state, name, args) {
|
||||
TAG: function handleTagDirective(state, name, args) {
|
||||
|
||||
var handle, prefix;
|
||||
|
||||
|
@ -370,7 +372,7 @@ function testDocumentSeparator(state) {
|
|||
// in parent on each call, for efficiency. No needs to test here again.
|
||||
if ((0x2D/* - */ === ch || 0x2E/* . */ === ch) &&
|
||||
state.input.charCodeAt(_position + 1) === ch &&
|
||||
state.input.charCodeAt(_position+ 2) === ch) {
|
||||
state.input.charCodeAt(_position + 2) === ch) {
|
||||
|
||||
_position += 3;
|
||||
|
||||
|
@ -440,7 +442,7 @@ function readPlainScalar(state, nodeIndent, withinFlowCollection) {
|
|||
|
||||
while (0 !== ch) {
|
||||
if (0x3A/* : */ === ch) {
|
||||
following = state.input.charCodeAt(state.position+1);
|
||||
following = state.input.charCodeAt(state.position + 1);
|
||||
|
||||
if (is_WS_OR_EOL(following) ||
|
||||
withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
||||
|
@ -495,11 +497,11 @@ function readPlainScalar(state, nodeIndent, withinFlowCollection) {
|
|||
|
||||
if (state.result) {
|
||||
return true;
|
||||
} else {
|
||||
state.kind = _kind;
|
||||
state.result = _result;
|
||||
return false;
|
||||
}
|
||||
|
||||
state.kind = _kind;
|
||||
state.result = _result;
|
||||
return false;
|
||||
}
|
||||
|
||||
function readSingleQuotedScalar(state, nodeIndent) {
|
||||
|
@ -578,7 +580,7 @@ function readDoubleQuotedScalar(state, nodeIndent) {
|
|||
if (is_EOL(ch)) {
|
||||
skipSeparationSpace(state, false, nodeIndent);
|
||||
|
||||
//TODO: rework to inline fn with no type cast?
|
||||
// TODO: rework to inline fn with no type cast?
|
||||
} else if (ch < 256 && simpleEscapeCheck[ch]) {
|
||||
state.result += simpleEscapeMap[ch];
|
||||
state.position++;
|
||||
|
@ -644,11 +646,11 @@ function readFlowCollection(state, nodeIndent) {
|
|||
ch = state.input.charCodeAt(state.position);
|
||||
|
||||
if (ch === 0x5B/* [ */) {
|
||||
terminator = 0x5D/* ] */;
|
||||
terminator = 0x5D;/* ] */
|
||||
isMapping = false;
|
||||
_result = [];
|
||||
} else if (ch === 0x7B/* { */) {
|
||||
terminator = 0x7D/* } */;
|
||||
terminator = 0x7D;/* } */
|
||||
isMapping = true;
|
||||
_result = {};
|
||||
} else {
|
||||
|
@ -850,24 +852,20 @@ function readBlockScalar(state, nodeIndent) {
|
|||
}
|
||||
|
||||
// Literal style: just add exact number of line breaks between content lines.
|
||||
} else {
|
||||
|
||||
} else if (detectedIndent) {
|
||||
// If current line isn't the first one - count line break from the last content line.
|
||||
if (detectedIndent) {
|
||||
state.result += common.repeat('\n', emptyLines + 1);
|
||||
|
||||
state.result += common.repeat('\n', emptyLines + 1);
|
||||
} else {
|
||||
// In case of the first content line - count only empty lines.
|
||||
} else {
|
||||
state.result += common.repeat('\n', emptyLines);
|
||||
}
|
||||
}
|
||||
|
||||
detectedIndent = true;
|
||||
emptyLines = 0;
|
||||
captureStart = state.position;
|
||||
|
||||
while (!is_EOL(ch) && (0 !== ch))
|
||||
{ ch = state.input.charCodeAt(++state.position); }
|
||||
while (!is_EOL(ch) && (0 !== ch)) {
|
||||
ch = state.input.charCodeAt(++state.position);
|
||||
}
|
||||
|
||||
captureSegment(state, captureStart, state.position, false);
|
||||
}
|
||||
|
@ -933,9 +931,8 @@ function readBlockSequence(state, nodeIndent) {
|
|||
state.kind = 'sequence';
|
||||
state.result = _result;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function readBlockMapping(state, nodeIndent, flowIndent) {
|
||||
|
@ -1515,10 +1512,18 @@ function loadDocuments(input, options) {
|
|||
input = String(input);
|
||||
options = options || {};
|
||||
|
||||
if (0 !== input.length &&
|
||||
0x0A/* LF */ !== input.charCodeAt(input.length - 1) &&
|
||||
0x0D/* CR */ !== input.charCodeAt(input.length - 1)) {
|
||||
input += '\n';
|
||||
if (input.length !== 0) {
|
||||
|
||||
// Add tailing `\n` if not exists
|
||||
if (0x0A/* LF */ !== input.charCodeAt(input.length - 1) &&
|
||||
0x0D/* CR */ !== input.charCodeAt(input.length - 1)) {
|
||||
input += '\n';
|
||||
}
|
||||
|
||||
// Strip BOM
|
||||
if (input.charCodeAt(0) === 0xFEFF) {
|
||||
input = input.slice(1);
|
||||
}
|
||||
}
|
||||
|
||||
var state = new State(input, options);
|
||||
|
@ -1556,12 +1561,12 @@ function load(input, options) {
|
|||
var documents = loadDocuments(input, options), index, length;
|
||||
|
||||
if (0 === documents.length) {
|
||||
/*eslint-disable no-undefined*/
|
||||
return undefined;
|
||||
} else if (1 === documents.length) {
|
||||
return documents[0];
|
||||
} else {
|
||||
throw new YAMLException('expected a single document in the stream, but found more');
|
||||
}
|
||||
throw new YAMLException('expected a single document in the stream, but found more');
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
/*eslint-disable max-len*/
|
||||
|
||||
var common = require('./common');
|
||||
var YAMLException = require('./exception');
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
/*eslint-disable no-bitwise*/
|
||||
|
||||
// A trick for browserified version.
|
||||
// Since we make browserifier to ignore `buffer` module, NodeBuffer will be undefined
|
||||
|
@ -19,7 +20,7 @@ function resolveYamlBinary(data) {
|
|||
var code, idx, bitlen = 0, len = 0, max = data.length, map = BASE64_MAP;
|
||||
|
||||
// Convert one by one.
|
||||
for (idx = 0; idx < max; idx ++) {
|
||||
for (idx = 0; idx < max; idx++) {
|
||||
code = map.indexOf(data.charAt(idx));
|
||||
|
||||
// Skip CR/LF
|
||||
|
@ -57,7 +58,7 @@ function constructYamlBinary(data) {
|
|||
|
||||
// Dump tail
|
||||
|
||||
tailbits = (max % 4)*6;
|
||||
tailbits = (max % 4) * 6;
|
||||
|
||||
if (tailbits === 0) {
|
||||
result.push((bits >> 16) & 0xFF);
|
||||
|
|
|
@ -55,9 +55,8 @@ function constructYamlFloat(data) {
|
|||
|
||||
return sign * value;
|
||||
|
||||
} else {
|
||||
return sign * parseFloat(value, 10);
|
||||
}
|
||||
return sign * parseFloat(value, 10);
|
||||
}
|
||||
|
||||
function representYamlFloat(object, style) {
|
||||
|
@ -90,9 +89,8 @@ function representYamlFloat(object, style) {
|
|||
}
|
||||
} else if (common.isNegativeZero(object)) {
|
||||
return '-0.0';
|
||||
} else {
|
||||
return object.toString(10);
|
||||
}
|
||||
return object.toString(10);
|
||||
}
|
||||
|
||||
function isFloat(object) {
|
||||
|
|
|
@ -38,7 +38,7 @@ function resolveYamlInteger(data) {
|
|||
|
||||
if (ch === '0') {
|
||||
// 0
|
||||
if (index+1 === max) { return true; }
|
||||
if (index + 1 === max) { return true; }
|
||||
ch = data[++index];
|
||||
|
||||
// base 2, base 8, base 16
|
||||
|
|
|
@ -65,7 +65,8 @@ function constructJavascriptFunction(data) {
|
|||
|
||||
// Esprima's ranges include the first '{' and the last '}' characters on
|
||||
// function expressions. So cut them out.
|
||||
return new Function(params, source.slice(body[0]+1, body[1]-1));
|
||||
/*eslint-disable no-new-func*/
|
||||
return new Function(params, source.slice(body[0] + 1, body[1] - 1));
|
||||
}
|
||||
|
||||
function representJavascriptFunction(object /*, style*/) {
|
||||
|
|
|
@ -7,6 +7,7 @@ function resolveJavascriptUndefined() {
|
|||
}
|
||||
|
||||
function constructJavascriptUndefined() {
|
||||
/*eslint-disable no-undefined*/
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue