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
|
2.2.0 / 2015-03-26
|
||||||
==================
|
==================
|
||||||
|
|
||||||
|
|
|
@ -25,82 +25,85 @@ Chai offers a robust Plugin architecture for extending Chai's assertions and int
|
||||||
### Contributors
|
### Contributors
|
||||||
|
|
||||||
project : chai
|
project : chai
|
||||||
repo age : 3 years, 3 months
|
repo age : 3 years, 5 months
|
||||||
active : 232 days
|
active : 244 days
|
||||||
commits : 879
|
commits : 900
|
||||||
files : 59
|
files : 59
|
||||||
authors :
|
authors :
|
||||||
555 Jake Luer 63.1%
|
555 Jake Luer 61.7%
|
||||||
79 Veselin Todorov 9.0%
|
79 Veselin Todorov 8.8%
|
||||||
43 Domenic Denicola 4.9%
|
52 Keith Cirkel 5.8%
|
||||||
41 Keith Cirkel 4.7%
|
43 Domenic Denicola 4.8%
|
||||||
14 Joshua Perry 1.6%
|
14 Joshua Perry 1.6%
|
||||||
8 Chris Polis 0.9%
|
8 Chris Polis 0.9%
|
||||||
6 Ruben Verborgh 0.7%
|
6 Ruben Verborgh 0.7%
|
||||||
6 Ian Zamojc 0.7%
|
6 Ian Zamojc 0.7%
|
||||||
5 leider 0.6%
|
|
||||||
5 George Kats 0.6%
|
5 George Kats 0.6%
|
||||||
|
5 leider 0.6%
|
||||||
5 Scott Nonnenberg 0.6%
|
5 Scott Nonnenberg 0.6%
|
||||||
5 Jo Liss 0.6%
|
|
||||||
5 Juliusz Gonera 0.6%
|
5 Juliusz Gonera 0.6%
|
||||||
4 Veselin 0.5%
|
5 Jo Liss 0.6%
|
||||||
4 Nick Heiner 0.5%
|
4 Jérémie Astori 0.4%
|
||||||
4 David da Silva 0.5%
|
4 John Firebaugh 0.4%
|
||||||
4 Chris Jones 0.5%
|
4 charlierudolph 0.4%
|
||||||
4 josher19 0.5%
|
4 Veselin 0.4%
|
||||||
4 John Firebaugh 0.5%
|
4 Chris Jones 0.4%
|
||||||
4 Max Edmands 0.5%
|
4 Nick Heiner 0.4%
|
||||||
4 charlierudolph 0.5%
|
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 Ryunosuke SATO 0.3%
|
||||||
|
3 Jake Rosoman 0.3%
|
||||||
|
3 Duncan Beevers 0.3%
|
||||||
3 Jason Karns 0.3%
|
3 Jason Karns 0.3%
|
||||||
3 Jeff Barczewski 0.3%
|
3 Jeff Barczewski 0.3%
|
||||||
3 Andrei Neculau 0.3%
|
3 Andrei Neculau 0.3%
|
||||||
3 Duncan Beevers 0.3%
|
2 eldritch fossicker 0.2%
|
||||||
3 Jake Rosoman 0.3%
|
|
||||||
2 Teddy Cross 0.2%
|
|
||||||
2 Bartvds 0.2%
|
2 Bartvds 0.2%
|
||||||
2 Edwin Shao 0.2%
|
2 Edwin Shao 0.2%
|
||||||
2 Gregg Lind 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 Jakub Nešetřil 0.2%
|
||||||
2 eldritch fossicker 0.2%
|
2 Roman Masek 0.2%
|
||||||
1 Adam Hull 0.1%
|
2 Teddy Cross 0.2%
|
||||||
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%
|
|
||||||
1 Jesse McCarthy 0.1%
|
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 Kilian Ciuffolo 0.1%
|
||||||
1 Luís Cardoso 0.1%
|
1 Luís Cardoso 0.1%
|
||||||
1 Martin Middel 0.1%
|
1 Martin Middel 0.1%
|
||||||
1 Mathias Schreck 0.1%
|
1 Mathias Schreck 0.1%
|
||||||
|
1 Danilo Vaz 0.1%
|
||||||
1 Michael Lange 0.1%
|
1 Michael Lange 0.1%
|
||||||
|
1 Mitchell Johnson 0.1%
|
||||||
|
1 DD 0.1%
|
||||||
1 Niklas Närhinen 0.1%
|
1 Niklas Närhinen 0.1%
|
||||||
1 Paul Miller 0.1%
|
1 Paul Miller 0.1%
|
||||||
1 Refael Ackermann 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 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 Victor Costan 0.1%
|
||||||
1 Vinay Pulim 0.1%
|
1 Vinay Pulim 0.1%
|
||||||
1 Virginie BARDALES 0.1%
|
1 Virginie BARDALES 0.1%
|
||||||
1 Vlad GURDIGA 0.1%
|
1 Vlad GURDIGA 0.1%
|
||||||
|
1 Brandon Payton 0.1%
|
||||||
|
1 Adam Hull 0.1%
|
||||||
1 ericdouglas 0.1%
|
1 ericdouglas 0.1%
|
||||||
|
1 Benjamin Horsleben 0.1%
|
||||||
1 laconbass 0.1%
|
1 laconbass 0.1%
|
||||||
|
1 Anand Patil 0.1%
|
||||||
1 mohayonao 0.1%
|
1 mohayonao 0.1%
|
||||||
1 piecioshka 0.1%
|
1 piecioshka 0.1%
|
||||||
1 root 0.1%
|
1 root 0.1%
|
||||||
1 shinnn 0.1%
|
1 Julien Wajsberg 0.1%
|
||||||
|
1 Jeff Welch 0.1%
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,36 @@
|
||||||
# Release Notes
|
# 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
|
## 2.2.0 / 2015-03-26
|
||||||
|
|
||||||
Deep property strings can now be escaped using `\\` - for example:
|
Deep property strings can now be escaped using `\\` - for example:
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "chai",
|
"name": "chai",
|
||||||
"version": "2.2.0",
|
"version": "2.3.0",
|
||||||
"description": "BDD/TDD assertion library for node.js and the browser. Test framework agnostic.",
|
"description": "BDD/TDD assertion library for node.js and the browser. Test framework agnostic.",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|
|
@ -678,7 +678,7 @@ var used = []
|
||||||
* Chai version
|
* Chai version
|
||||||
*/
|
*/
|
||||||
|
|
||||||
exports.version = '2.2.0';
|
exports.version = '2.3.0';
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Assertion Error
|
* Assertion Error
|
||||||
|
@ -1051,7 +1051,7 @@ module.exports = function (chai, _) {
|
||||||
* ### .any
|
* ### .any
|
||||||
*
|
*
|
||||||
* Sets the `any` flag, (opposite of the `all` flag)
|
* 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');
|
* expect(foo).to.have.any.keys('bar', 'baz');
|
||||||
*
|
*
|
||||||
|
@ -1068,7 +1068,7 @@ module.exports = function (chai, _) {
|
||||||
/**
|
/**
|
||||||
* ### .all
|
* ### .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.
|
* later used by the `keys` assertion.
|
||||||
*
|
*
|
||||||
* expect(foo).to.have.all.keys('bar', 'baz');
|
* expect(foo).to.have.all.keys('bar', 'baz');
|
||||||
|
@ -1249,7 +1249,7 @@ module.exports = function (chai, _) {
|
||||||
* Asserts that the target is `null`.
|
* Asserts that the target is `null`.
|
||||||
*
|
*
|
||||||
* expect(null).to.be.null;
|
* expect(null).to.be.null;
|
||||||
* expect(undefined).not.to.be.null;
|
* expect(undefined).to.not.be.null;
|
||||||
*
|
*
|
||||||
* @name null
|
* @name null
|
||||||
* @api public
|
* @api public
|
||||||
|
@ -1725,7 +1725,7 @@ module.exports = function (chai, _) {
|
||||||
* green: { tea: 'matcha' }
|
* green: { tea: 'matcha' }
|
||||||
* , teas: [ 'chai', 'matcha', { tea: 'konacha' } ]
|
* , teas: [ 'chai', 'matcha', { tea: 'konacha' } ]
|
||||||
* };
|
* };
|
||||||
*
|
*
|
||||||
* expect(deepObj).to.have.deep.property('green.tea', 'matcha');
|
* 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[1]', 'matcha');
|
||||||
* expect(deepObj).to.have.deep.property('teas[2].tea', 'konacha');
|
* expect(deepObj).to.have.deep.property('teas[2].tea', 'konacha');
|
||||||
|
@ -1846,6 +1846,55 @@ module.exports = function (chai, _) {
|
||||||
Assertion.addMethod('ownProperty', assertOwnProperty);
|
Assertion.addMethod('ownProperty', assertOwnProperty);
|
||||||
Assertion.addMethod('haveOwnProperty', 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)
|
* ### .length(value)
|
||||||
*
|
*
|
||||||
|
@ -1947,30 +1996,30 @@ module.exports = function (chai, _) {
|
||||||
* ### .keys(key1, [key2], [...])
|
* ### .keys(key1, [key2], [...])
|
||||||
*
|
*
|
||||||
* Asserts that the target contains any or all of the passed-in keys.
|
* 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.
|
* what will pass.
|
||||||
*
|
*
|
||||||
* When used in conjunction with `any`, at least one key that is passed
|
* 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
|
* 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`
|
* 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
|
* should be used in the assertion. If neither are used, the assertion is
|
||||||
* defaulted to `all`.
|
* 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.
|
* 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
|
* 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
|
* 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).
|
* 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', 'baz');
|
||||||
* expect({ foo: 1, bar: 2 }).to.have.any.keys('foo');
|
* 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('bar', 'baz');
|
||||||
* expect({ foo: 1, bar: 2 }).to.contain.any.keys(['foo']);
|
* 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.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', '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', 'foo']);
|
||||||
* expect({ foo: 1, bar: 2, baz: 3 }).to.contain.all.keys([{'bar': 6}}]);
|
* expect({ foo: 1, bar: 2, baz: 3 }).to.contain.all.keys([{'bar': 6}}]);
|
||||||
*
|
*
|
||||||
|
|
|
@ -11,7 +11,7 @@ var used = []
|
||||||
* Chai version
|
* Chai version
|
||||||
*/
|
*/
|
||||||
|
|
||||||
exports.version = '2.2.0';
|
exports.version = '2.3.0';
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Assertion Error
|
* Assertion Error
|
||||||
|
|
|
@ -50,7 +50,5 @@
|
||||||
],
|
],
|
||||||
"directories": {},
|
"directories": {},
|
||||||
"_shasum": "c7f85438fdd466bc7ca16ab90c81513797a5d23b",
|
"_shasum": "c7f85438fdd466bc7ca16ab90c81513797a5d23b",
|
||||||
"_resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.0.0.tgz",
|
"_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"
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,5 @@
|
||||||
],
|
],
|
||||||
"directories": {},
|
"directories": {},
|
||||||
"_shasum": "0ba5ec2a885640e470ea4e8505971900dac58822",
|
"_shasum": "0ba5ec2a885640e470ea4e8505971900dac58822",
|
||||||
"_resolved": "https://registry.npmjs.org/type-detect/-/type-detect-0.1.1.tgz",
|
"_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"
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,8 +37,6 @@
|
||||||
"mocha-lcov-reporter": "0.0.1",
|
"mocha-lcov-reporter": "0.0.1",
|
||||||
"simple-assert": "*"
|
"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": {
|
"bugs": {
|
||||||
"url": "https://github.com/chaijs/deep-eql/issues"
|
"url": "https://github.com/chaijs/deep-eql/issues"
|
||||||
},
|
},
|
||||||
|
@ -61,6 +59,5 @@
|
||||||
],
|
],
|
||||||
"directories": {},
|
"directories": {},
|
||||||
"_shasum": "ef558acab8de25206cd713906d74e56930eb69f2",
|
"_shasum": "ef558acab8de25206cd713906d74e56930eb69f2",
|
||||||
"_resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-0.1.3.tgz",
|
"_resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-0.1.3.tgz"
|
||||||
"homepage": "https://github.com/chaijs/deep-eql"
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
"email": "john.firebaugh@gmail.com"
|
"email": "john.firebaugh@gmail.com"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"version": "2.2.0",
|
"version": "2.3.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/chaijs/chai"
|
"url": "https://github.com/chaijs/chai"
|
||||||
|
@ -58,29 +58,34 @@
|
||||||
"karma-mocha": "*",
|
"karma-mocha": "*",
|
||||||
"karma-sauce-launcher": "0.2.x",
|
"karma-sauce-launcher": "0.2.x",
|
||||||
"karma-phantomjs-launcher": "0.1.1",
|
"karma-phantomjs-launcher": "0.1.1",
|
||||||
|
"karma-firefox-launcher": "^0.1.4",
|
||||||
"mocha": "1.21.x",
|
"mocha": "1.21.x",
|
||||||
"istanbul": "0.2.x"
|
"istanbul": "0.2.x"
|
||||||
},
|
},
|
||||||
"gitHead": "57df3888f66c4b34923ce8576aa93855a0ec2f75",
|
"gitHead": "3de55026458ace296df354757361953ec1949859",
|
||||||
"_id": "chai@2.2.0",
|
"_id": "chai@2.3.0",
|
||||||
"_shasum": "d21135623bd393ad4702d94536eca482ad78d01d",
|
"_shasum": "8a2f6a34748da801090fd73287b2aa739a4e909a",
|
||||||
"_from": "chai@*",
|
"_from": "chai@2.3.0",
|
||||||
"_npmVersion": "1.4.28",
|
"_npmVersion": "2.7.6",
|
||||||
|
"_nodeVersion": "0.10.36",
|
||||||
"_npmUser": {
|
"_npmUser": {
|
||||||
"name": "jakeluer",
|
"name": "chaijs",
|
||||||
"email": "jake@alogicalparadox.com"
|
"email": "chaijs@keithcirkel.co.uk"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"shasum": "8a2f6a34748da801090fd73287b2aa739a4e909a",
|
||||||
|
"tarball": "http://registry.npmjs.org/chai/-/chai-2.3.0.tgz"
|
||||||
},
|
},
|
||||||
"maintainers": [
|
"maintainers": [
|
||||||
{
|
{
|
||||||
"name": "jakeluer",
|
"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": {},
|
"directories": {},
|
||||||
"_resolved": "https://registry.npmjs.org/chai/-/chai-2.2.0.tgz",
|
"_resolved": "https://registry.npmjs.org/chai/-/chai-2.3.0.tgz"
|
||||||
"readme": "ERROR: No README data found!"
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
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
|
Our lovely and talented contributors are listed here: http://github.com/jashkenas/coffeescript/contributors
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "coffee-script",
|
"name": "coffee-script",
|
||||||
"version": "1.9.1",
|
"version": "1.9.3",
|
||||||
"main": [
|
"main": [
|
||||||
"lib/coffee-script/coffee-script.js"
|
"lib/coffee-script/coffee-script.js"
|
||||||
],
|
],
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Generated by CoffeeScript 1.9.1
|
// Generated by CoffeeScript 1.9.3
|
||||||
(function() {
|
(function() {
|
||||||
var CoffeeScript, compile, runScripts,
|
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; };
|
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) {
|
fn = function(script, i) {
|
||||||
var options;
|
var options, source;
|
||||||
options = {
|
options = {
|
||||||
literate: script.type === coffeetypes[1]
|
literate: script.type === coffeetypes[1]
|
||||||
};
|
};
|
||||||
if (script.src) {
|
source = script.src || script.getAttribute('data-src');
|
||||||
return CoffeeScript.load(script.src, function(param) {
|
if (source) {
|
||||||
|
return CoffeeScript.load(source, function(param) {
|
||||||
coffees[i] = param;
|
coffees[i] = param;
|
||||||
return execute();
|
return execute();
|
||||||
}, options, true);
|
}, options, true);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Generated by CoffeeScript 1.9.1
|
// Generated by CoffeeScript 1.9.3
|
||||||
(function() {
|
(function() {
|
||||||
var CoffeeScript, cakefileDirectory, fatalError, fs, helpers, missingTask, oparse, options, optparse, path, printTasks, switches, tasks;
|
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() {
|
(function() {
|
||||||
var Lexer, SourceMap, base, compile, ext, formatSourcePosition, fs, getSourceMap, helpers, i, len, lexer, parser, path, ref, sourceMaps, vm, withPrettyErrors,
|
var Lexer, SourceMap, base, compile, ext, formatSourcePosition, fs, getSourceMap, helpers, i, len, lexer, parser, path, ref, sourceMaps, vm, withPrettyErrors,
|
||||||
hasProp = {}.hasOwnProperty,
|
hasProp = {}.hasOwnProperty,
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
SourceMap = require('./sourcemap');
|
SourceMap = require('./sourcemap');
|
||||||
|
|
||||||
exports.VERSION = '1.9.1';
|
exports.VERSION = '1.9.3';
|
||||||
|
|
||||||
exports.FILE_EXTENSIONS = ['.coffee', '.litcoffee', '.coffee.md'];
|
exports.FILE_EXTENSIONS = ['.coffee', '.litcoffee', '.coffee.md'];
|
||||||
|
|
||||||
|
@ -34,6 +34,9 @@
|
||||||
return fn.call(this, code, options);
|
return fn.call(this, code, options);
|
||||||
} catch (_error) {
|
} catch (_error) {
|
||||||
err = _error;
|
err = _error;
|
||||||
|
if (typeof code !== 'string') {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
throw helpers.updateSyntaxError(err, code, options.filename);
|
throw helpers.updateSyntaxError(err, code, options.filename);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -71,7 +74,7 @@
|
||||||
for (i = 0, len = fragments.length; i < len; i++) {
|
for (i = 0, len = fragments.length; i < len; i++) {
|
||||||
fragment = fragments[i];
|
fragment = fragments[i];
|
||||||
if (options.sourceMap) {
|
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], {
|
map.add([fragment.locationData.first_line, fragment.locationData.first_column], [currentLine, currentColumn], {
|
||||||
noReplace: true
|
noReplace: true
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// Generated by CoffeeScript 1.9.1
|
// Generated by CoffeeScript 1.9.3
|
||||||
(function() {
|
(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; };
|
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');
|
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.';
|
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 = {};
|
opts = {};
|
||||||
|
|
||||||
|
@ -49,14 +49,16 @@
|
||||||
|
|
||||||
optionParser = null;
|
optionParser = null;
|
||||||
|
|
||||||
jsToSources = {};
|
|
||||||
|
|
||||||
exports.run = function() {
|
exports.run = function() {
|
||||||
var i, len, literals, ref1, replCliOpts, results, source;
|
var i, len, literals, ref1, replCliOpts, results, source;
|
||||||
parseOptions();
|
parseOptions();
|
||||||
replCliOpts = {
|
replCliOpts = {
|
||||||
useGlobal: true
|
useGlobal: true
|
||||||
};
|
};
|
||||||
|
if (opts.require) {
|
||||||
|
opts.prelude = makePrelude(opts.require);
|
||||||
|
}
|
||||||
|
replCliOpts.prelude = opts.prelude;
|
||||||
if (opts.nodejs) {
|
if (opts.nodejs) {
|
||||||
return forkNode();
|
return forkNode();
|
||||||
}
|
}
|
||||||
|
@ -98,6 +100,17 @@
|
||||||
return results;
|
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) {
|
compilePath = function(source, topLevel, base) {
|
||||||
var code, err, file, files, i, len, results, stats;
|
var code, err, file, files, i, len, results, stats;
|
||||||
if (indexOf.call(sources, source) >= 0 || watchedDirs[source] || !topLevel && (notSources[source] || hidden(source))) {
|
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());
|
return printLine(CoffeeScript.nodes(t.input, t.options).toString().trim());
|
||||||
} else if (o.run) {
|
} else if (o.run) {
|
||||||
CoffeeScript.register();
|
CoffeeScript.register();
|
||||||
|
if (opts.prelude) {
|
||||||
|
CoffeeScript["eval"](opts.prelude, t.options);
|
||||||
|
}
|
||||||
return CoffeeScript.run(t.input, t.options);
|
return CoffeeScript.run(t.input, t.options);
|
||||||
} else if (o.join && t.file !== o.join) {
|
} else if (o.join && t.file !== o.join) {
|
||||||
if (helpers.isLiterate(file)) {
|
if (helpers.isLiterate(file)) {
|
||||||
|
@ -468,13 +484,6 @@
|
||||||
}
|
}
|
||||||
sourceMapPath = outputPath(sourcePath, base, ".js.map");
|
sourceMapPath = outputPath(sourcePath, base, ".js.map");
|
||||||
jsDir = path.dirname(jsPath);
|
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() {
|
compile = function() {
|
||||||
if (opts.compile) {
|
if (opts.compile) {
|
||||||
if (js.length <= 0) {
|
if (js.length <= 0) {
|
||||||
|
@ -582,7 +591,7 @@
|
||||||
p = spawn(process.execPath, nodeArgs.concat(args), {
|
p = spawn(process.execPath, nodeArgs.concat(args), {
|
||||||
cwd: process.cwd(),
|
cwd: process.cwd(),
|
||||||
env: process.env,
|
env: process.env,
|
||||||
customFds: [0, 1, 2]
|
stdio: [0, 1, 2]
|
||||||
});
|
});
|
||||||
return p.on('exit', function(code) {
|
return p.on('exit', function(code) {
|
||||||
return process.exit(code);
|
return process.exit(code);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Generated by CoffeeScript 1.9.1
|
// Generated by CoffeeScript 1.9.3
|
||||||
(function() {
|
(function() {
|
||||||
var Parser, alt, alternatives, grammar, name, o, operators, token, tokens, unwrap;
|
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() {
|
(function() {
|
||||||
var buildLocationData, extend, flatten, ref, repeat, syntaxErrorToString;
|
var buildLocationData, extend, flatten, ref, repeat, syntaxErrorToString;
|
||||||
|
|
||||||
|
@ -201,7 +201,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
syntaxErrorToString = function() {
|
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)) {
|
if (!(this.code && this.location)) {
|
||||||
return Error.prototype.toString.call(this);
|
return Error.prototype.toString.call(this);
|
||||||
}
|
}
|
||||||
|
@ -218,9 +218,9 @@
|
||||||
end = first_line === last_line ? last_column + 1 : codeLine.length;
|
end = first_line === last_line ? last_column + 1 : codeLine.length;
|
||||||
marker = codeLine.slice(0, start).replace(/[^\s]/g, ' ') + repeat('^', end - start);
|
marker = codeLine.slice(0, start).replace(/[^\s]/g, ' ') + repeat('^', end - start);
|
||||||
if (typeof process !== "undefined" && process !== null) {
|
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) {
|
colorize = function(str) {
|
||||||
return "\x1B[1;31m" + str + "\x1B[0m";
|
return "\x1B[1;31m" + str + "\x1B[0m";
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Generated by CoffeeScript 1.9.1
|
// Generated by CoffeeScript 1.9.3
|
||||||
(function() {
|
(function() {
|
||||||
var key, ref, val;
|
var key, ref, val;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Generated by CoffeeScript 1.9.1
|
// Generated by CoffeeScript 1.9.3
|
||||||
(function() {
|
(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,
|
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; };
|
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() {
|
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))) {
|
if (!(match = IDENTIFIER.exec(this.chunk))) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -118,6 +118,7 @@
|
||||||
}
|
}
|
||||||
if (!forcedIdentifier) {
|
if (!forcedIdentifier) {
|
||||||
if (indexOf.call(COFFEE_ALIASES, id) >= 0) {
|
if (indexOf.call(COFFEE_ALIASES, id) >= 0) {
|
||||||
|
alias = id;
|
||||||
id = COFFEE_ALIAS_MAP[id];
|
id = COFFEE_ALIAS_MAP[id];
|
||||||
}
|
}
|
||||||
tag = (function() {
|
tag = (function() {
|
||||||
|
@ -142,6 +143,9 @@
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
tagToken = this.token(tag, id, 0, idLength);
|
tagToken = this.token(tag, id, 0, idLength);
|
||||||
|
if (alias) {
|
||||||
|
tagToken.origin = [tag, alias, tagToken[2]];
|
||||||
|
}
|
||||||
tagToken.variable = !forcedIdentifier;
|
tagToken.variable = !forcedIdentifier;
|
||||||
if (poppedToken) {
|
if (poppedToken) {
|
||||||
ref5 = [poppedToken[2].first_line, poppedToken[2].first_column], tagToken[2].first_line = ref5[0], tagToken[2].first_column = ref5[1];
|
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;
|
heredoc = quote.length === 3;
|
||||||
ref2 = this.matchWithInterpolations(regex, quote), tokens = ref2.tokens, end = ref2.index;
|
ref2 = this.matchWithInterpolations(regex, quote), tokens = ref2.tokens, end = ref2.index;
|
||||||
$ = tokens.length - 1;
|
$ = tokens.length - 1;
|
||||||
delimiter = quote[0];
|
delimiter = quote.charAt(0);
|
||||||
if (heredoc) {
|
if (heredoc) {
|
||||||
indent = null;
|
indent = null;
|
||||||
doc = ((function() {
|
doc = ((function() {
|
||||||
|
@ -500,6 +504,9 @@
|
||||||
ref2 = this.tokens, prev = ref2[ref2.length - 1];
|
ref2 = this.tokens, prev = ref2[ref2.length - 1];
|
||||||
if (value === '=' && prev) {
|
if (value === '=' && prev) {
|
||||||
if (!prev[1].reserved && (ref3 = prev[1], indexOf.call(JS_FORBIDDEN, ref3) >= 0)) {
|
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]);
|
this.error("reserved word '" + prev[1] + "' can't be assigned", prev[2]);
|
||||||
}
|
}
|
||||||
if ((ref4 = prev[1]) === '||' || ref4 === '&&') {
|
if ((ref4 = prev[1]) === '||' || ref4 === '&&') {
|
||||||
|
@ -946,7 +953,7 @@
|
||||||
|
|
||||||
HEREDOC_INDENT = /\n+([^\n\S]*)(?=\S)/g;
|
HEREDOC_INDENT = /\n+([^\n\S]*)(?=\S)/g;
|
||||||
|
|
||||||
REGEX = /^\/(?!\/)((?:[^[\/\n\\]|\\[^\n]|\[(?:\\[^\n]|[^\]\n\\])*])*)(\/)?/;
|
REGEX = /^\/(?!\/)((?:[^[\/\n\\]|\\[^\n]|\[(?:\\[^\n]|[^\]\n\\])*\])*)(\/)?/;
|
||||||
|
|
||||||
REGEX_FLAGS = /^\w*/;
|
REGEX_FLAGS = /^\w*/;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Generated by CoffeeScript 1.9.1
|
// Generated by CoffeeScript 1.9.3
|
||||||
(function() {
|
(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,
|
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; },
|
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) {
|
Base.prototype.compileClosure = function(o) {
|
||||||
var args, argumentsNode, func, jumpNode, meth, parts;
|
var args, argumentsNode, func, jumpNode, meth, parts, ref3;
|
||||||
if (jumpNode = this.jumps()) {
|
if (jumpNode = this.jumps()) {
|
||||||
jumpNode.error('cannot use a pure statement in an expression');
|
jumpNode.error('cannot use a pure statement in an expression');
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@
|
||||||
func = new Value(func, [new Access(new Literal(meth))]);
|
func = new Value(func, [new Access(new Literal(meth))]);
|
||||||
}
|
}
|
||||||
parts = (new Call(func, args)).compileNode(o);
|
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.unshift(this.makeCode("(yield* "));
|
||||||
parts.push(this.makeCode(")"));
|
parts.push(this.makeCode(")"));
|
||||||
}
|
}
|
||||||
|
@ -868,7 +868,7 @@
|
||||||
|
|
||||||
Comment.prototype.compileNode = function(o, level) {
|
Comment.prototype.compileNode = function(o, level) {
|
||||||
var code, comment;
|
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 : '') + " */";
|
code = "/*" + (multident(comment, this.tab)) + (indexOf.call(comment, '\n') >= 0 ? "\n" + this.tab : '') + " */";
|
||||||
if ((level || o.level) === LEVEL_TOP) {
|
if ((level || o.level) === LEVEL_TOP) {
|
||||||
code = o.indent + code;
|
code = o.indent + code;
|
||||||
|
@ -1311,7 +1311,7 @@
|
||||||
indent += TAB;
|
indent += TAB;
|
||||||
}
|
}
|
||||||
if (prop instanceof Assign && prop.variable instanceof Value && prop.variable.hasProperties()) {
|
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"]) {
|
if (prop instanceof Value && prop["this"]) {
|
||||||
prop = new Assign(prop.properties[0].name, prop, 'object');
|
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() {
|
(function() {
|
||||||
var LONG_FLAG, MULTI_FLAG, OPTIONAL, OptionParser, SHORT_FLAG, buildRule, buildRules, normalizeArguments, repeat;
|
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() {
|
(function() {
|
||||||
var CoffeeScript, Module, binary, child_process, ext, findExtension, fork, helpers, i, len, loadFile, path, ref;
|
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() {
|
(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');
|
fs = require('fs');
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
historyFile: process.env.HOME ? path.join(process.env.HOME, '.coffee_history') : void 0,
|
historyFile: process.env.HOME ? path.join(process.env.HOME, '.coffee_history') : void 0,
|
||||||
historyMaxInputSize: 10240,
|
historyMaxInputSize: 10240,
|
||||||
"eval": function(input, context, filename, cb) {
|
"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(/\uFF00/g, '\n');
|
||||||
input = input.replace(/^\(([\s\S]*)\n\)$/m, '$1');
|
input = input.replace(/^\(([\s\S]*)\n\)$/m, '$1');
|
||||||
ref1 = require('./nodes'), Block = ref1.Block, Assign = ref1.Assign, Value = ref1.Value, Literal = ref1.Literal;
|
ref1 = require('./nodes'), Block = ref1.Block, Assign = ref1.Assign, Value = ref1.Value, Literal = ref1.Literal;
|
||||||
|
@ -43,8 +43,7 @@
|
||||||
locals: Object.keys(context),
|
locals: Object.keys(context),
|
||||||
referencedVars: referencedVars
|
referencedVars: referencedVars
|
||||||
});
|
});
|
||||||
result = context === global ? vm.runInThisContext(js, filename) : vm.runInContext(js, context, filename);
|
return cb(null, runInContext(js, context, filename));
|
||||||
return cb(null, result);
|
|
||||||
} catch (_error) {
|
} catch (_error) {
|
||||||
err = _error;
|
err = _error;
|
||||||
updateSyntaxError(err, input);
|
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) {
|
addMultilineHandler = function(repl) {
|
||||||
var inputStream, multiline, nodeLineListener, origPrompt, outputStream, ref1, rli;
|
var inputStream, multiline, nodeLineListener, origPrompt, outputStream, ref1, rli;
|
||||||
rli = repl.rli, inputStream = repl.inputStream, outputStream = repl.outputStream;
|
rli = repl.rli, inputStream = repl.inputStream, outputStream = repl.outputStream;
|
||||||
|
@ -118,6 +125,7 @@
|
||||||
readFd = fs.openSync(filename, 'r');
|
readFd = fs.openSync(filename, 'r');
|
||||||
buffer = new Buffer(size);
|
buffer = new Buffer(size);
|
||||||
fs.readSync(readFd, buffer, 0, size, stat.size - size);
|
fs.readSync(readFd, buffer, 0, size, stat.size - size);
|
||||||
|
fs.close(readFd);
|
||||||
repl.rli.history = buffer.toString().split('\n').reverse();
|
repl.rli.history = buffer.toString().split('\n').reverse();
|
||||||
if (stat.size > maxSize) {
|
if (stat.size > maxSize) {
|
||||||
repl.rli.history.pop();
|
repl.rli.history.pop();
|
||||||
|
@ -135,7 +143,7 @@
|
||||||
return lastLine = code;
|
return lastLine = code;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
repl.rli.on('exit', function() {
|
repl.on('exit', function() {
|
||||||
return fs.close(fd);
|
return fs.close(fd);
|
||||||
});
|
});
|
||||||
return repl.commands[getCommandId(repl, 'history')] = {
|
return repl.commands[getCommandId(repl, 'history')] = {
|
||||||
|
@ -174,8 +182,13 @@
|
||||||
process.argv = ['coffee'].concat(process.argv.slice(2));
|
process.argv = ['coffee'].concat(process.argv.slice(2));
|
||||||
opts = merge(replDefaults, opts);
|
opts = merge(replDefaults, opts);
|
||||||
repl = nodeREPL.start(opts);
|
repl = nodeREPL.start(opts);
|
||||||
|
if (opts.prelude) {
|
||||||
|
runInContext(opts.prelude, repl.context, 'prelude');
|
||||||
|
}
|
||||||
repl.on('exit', function() {
|
repl.on('exit', function() {
|
||||||
return repl.outputStream.write('\n');
|
if (!repl.rli.closed) {
|
||||||
|
return repl.outputStream.write('\n');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
addMultilineHandler(repl);
|
addMultilineHandler(repl);
|
||||||
if (opts.historyFile) {
|
if (opts.historyFile) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Generated by CoffeeScript 1.9.1
|
// Generated by CoffeeScript 1.9.3
|
||||||
(function() {
|
(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,
|
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; },
|
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);
|
startImplicitCall(i + 1);
|
||||||
return forward(2);
|
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);
|
startImplicitCall(i + 1);
|
||||||
stack.push(['INDENT', i + 2]);
|
stack.push(['INDENT', i + 2]);
|
||||||
return forward(3);
|
return forward(3);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// Generated by CoffeeScript 1.9.1
|
// Generated by CoffeeScript 1.9.3
|
||||||
(function() {
|
(function() {
|
||||||
var Scope,
|
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; };
|
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() {
|
(function() {
|
||||||
var LineMap, SourceMap;
|
var LineMap, SourceMap;
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Jeremy Ashkenas"
|
"name": "Jeremy Ashkenas"
|
||||||
},
|
},
|
||||||
"version": "1.9.1",
|
"version": "1.9.3",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.8.0"
|
"node": ">=0.8.0"
|
||||||
|
@ -43,10 +43,10 @@
|
||||||
"underscore": "~1.5.2",
|
"underscore": "~1.5.2",
|
||||||
"docco": "~0.7.0"
|
"docco": "~0.7.0"
|
||||||
},
|
},
|
||||||
"gitHead": "533ad8afe920b2dbf64ffb00efda45648242cc24",
|
"gitHead": "c37f284771e10b36239c714dcc40827510a6df5f",
|
||||||
"_id": "coffee-script@1.9.1",
|
"_id": "coffee-script@1.9.3",
|
||||||
"_shasum": "c458d02200f460d064a79cb6ab1ee6e2c9ca1c31",
|
"_shasum": "596e6e83fcfcb67c5964ab70d444beff0ac04ac7",
|
||||||
"_from": "coffee-script@1.9.1",
|
"_from": "coffee-script@1.9.3",
|
||||||
"_npmVersion": "1.4.28",
|
"_npmVersion": "1.4.28",
|
||||||
"_npmUser": {
|
"_npmUser": {
|
||||||
"name": "jashkenas",
|
"name": "jashkenas",
|
||||||
|
@ -63,9 +63,8 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"dist": {
|
"dist": {
|
||||||
"shasum": "c458d02200f460d064a79cb6ab1ee6e2c9ca1c31",
|
"shasum": "596e6e83fcfcb67c5964ab70d444beff0ac04ac7",
|
||||||
"tarball": "http://registry.npmjs.org/coffee-script/-/coffee-script-1.9.1.tgz"
|
"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",
|
"_resolved": "https://registry.npmjs.org/coffee-script/-/coffee-script-1.9.3.tgz"
|
||||||
"readme": "ERROR: No README data found!"
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
examples
|
examples
|
||||||
|
sandbox.js
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
# Travis optimizations, see http://docs.travis-ci.com/user/workers/container-based-infrastructure/
|
# Travis optimizations, see http://docs.travis-ci.com/user/workers/container-based-infrastructure/
|
||||||
sudo: false
|
sudo: false
|
||||||
cache:
|
|
||||||
directories:
|
#cache:
|
||||||
- node_modules
|
# directories:
|
||||||
install: npm update
|
# - node_modules
|
||||||
|
#install: npm update
|
||||||
|
|
||||||
language: node_js
|
language: node_js
|
||||||
|
|
||||||
|
@ -15,8 +16,9 @@ node_js:
|
||||||
deploy:
|
deploy:
|
||||||
provider: npm
|
provider: npm
|
||||||
email: marsup@gmail.com
|
email: marsup@gmail.com
|
||||||
|
edge: true
|
||||||
api_key:
|
api_key:
|
||||||
secure: IuIigctAboFy2AGAcv/jUgRaVEQr23FX8ao+MM5fvmVpRZ/isHNQdJ2y1AAnCu5mCU+FgjNaXw/sB37J3Le5emMKhZMivXMTwAuLIbusEiQI6lzXflE7/+QK59jEcf/e5o6guTCf3CLMKo/yCrROYc/5sBuZuUqX2yDS6acGmZs=
|
secure: kY6qx95hnKJkiuriRRizFf2k2hneCVbGjZEds81hyL0SscdaCpd2UbkeY3fL/XrFfJaagdmDdEQ+H+y8+kTzOID/9HVnpcwVSCrPG20+eHDYL6ZdZCFOsGqq0ggi38XBp7WS1AHvq3uDGTYzoJdQDgA6RNqIBBim+o3zUKRpu34=
|
||||||
on:
|
on:
|
||||||
branch: master
|
branch: master
|
||||||
tags: true
|
tags: true
|
||||||
|
|
|
@ -36,11 +36,12 @@ Lead Maintainer: [Nicolas Morel](https://github.com/marsup)
|
||||||
- [`any.unit(name)`](#anyunitname)
|
- [`any.unit(name)`](#anyunitname)
|
||||||
- [`any.options(options)`](#anyoptionsoptions)
|
- [`any.options(options)`](#anyoptionsoptions)
|
||||||
- [`any.strict(isStrict)`](#anystrictisstrict)
|
- [`any.strict(isStrict)`](#anystrictisstrict)
|
||||||
- [`any.default(value, [description])`](#anydefaultvalue-description)
|
- [`any.default([value, [description]])`](#anydefaultvalue-description)
|
||||||
- [`any.concat(schema)`](#anyconcatschema)
|
- [`any.concat(schema)`](#anyconcatschema)
|
||||||
- [`any.when(ref, options)`](#anywhenref-options)
|
- [`any.when(ref, options)`](#anywhenref-options)
|
||||||
- [`any.label(name)`](#anylabelname)
|
- [`any.label(name)`](#anylabelname)
|
||||||
- [`any.raw(isRaw)`](#anyrawisraw)
|
- [`any.raw(isRaw)`](#anyrawisraw)
|
||||||
|
- [`any.empty(schema)`](#anyemptyschema)
|
||||||
- [`array`](#array)
|
- [`array`](#array)
|
||||||
- [`array.sparse(enabled)`](#arraysparseenabled)
|
- [`array.sparse(enabled)`](#arraysparseenabled)
|
||||||
- [`array.single(enabled)`](#arraysingleenabled)
|
- [`array.single(enabled)`](#arraysingleenabled)
|
||||||
|
@ -69,6 +70,8 @@ Lead Maintainer: [Nicolas Morel](https://github.com/marsup)
|
||||||
- [`number.integer()`](#numberinteger)
|
- [`number.integer()`](#numberinteger)
|
||||||
- [`number.precision(limit)`](#numberprecisionlimit)
|
- [`number.precision(limit)`](#numberprecisionlimit)
|
||||||
- [`number.multiple(base)`](#numbermultiplebase)
|
- [`number.multiple(base)`](#numbermultiplebase)
|
||||||
|
- [`number.positive()`](#numberpositive)
|
||||||
|
- [`number.negative()`](#numbernegative)
|
||||||
- [`object`](#object)
|
- [`object`](#object)
|
||||||
- [`object.keys([schema])`](#objectkeysschema)
|
- [`object.keys([schema])`](#objectkeysschema)
|
||||||
- [`object.min(limit)`](#objectminlimit)
|
- [`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`.
|
- `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`.
|
- `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`.
|
- `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 (`{}`).
|
- `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'`.
|
- `presence` - sets the default presence requirements. Supported modes: `'optional'`, `'required'`, and `'forbidden'`.
|
||||||
Defaults to `'optional'`.
|
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();
|
var schema = Joi.any().strict();
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `any.default(value, [description])`
|
#### `any.default([value, [description]])`
|
||||||
|
|
||||||
Sets a default value if the original value is undefined where:
|
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
|
Note that if `value` is an object, any changes to the object after `default()` is called will change the reference
|
||||||
and any future assignment.
|
and any future assignment.
|
||||||
|
@ -476,7 +482,7 @@ Joi.validate({
|
||||||
#### `any.concat(schema)`
|
#### `any.concat(schema)`
|
||||||
|
|
||||||
Returns a new type that is the result of adding the rules of one type to another where:
|
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
|
```javascript
|
||||||
var a = Joi.string().valid('a');
|
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`
|
### `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()`.
|
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);
|
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`
|
### `object`
|
||||||
|
|
||||||
Generates a schema object that matches an object data type (as well as JSON strings that parsed into objects). Defaults
|
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"');
|
Hoek.assert(options.then !== undefined || options.otherwise !== undefined, 'options must have at least one of "then" or "otherwise"');
|
||||||
|
|
||||||
var obj = this.clone();
|
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 = {
|
var item = {
|
||||||
ref: Cast.ref(ref),
|
ref: Cast.ref(ref),
|
||||||
is: Cast.schema(options.is),
|
is: is,
|
||||||
then: options.then !== undefined ? Cast.schema(options.then) : undefined,
|
then: options.then !== undefined ? Cast.schema(options.then) : undefined,
|
||||||
otherwise: options.otherwise !== undefined ? Cast.schema(options.otherwise) : undefined
|
otherwise: options.otherwise !== undefined ? Cast.schema(options.otherwise) : undefined
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
// Load modules
|
// Load modules
|
||||||
|
|
||||||
var Path = require('path');
|
|
||||||
var Hoek = require('hoek');
|
var Hoek = require('hoek');
|
||||||
var Ref = require('./ref');
|
var Ref = require('./ref');
|
||||||
var Errors = require('./errors');
|
var Errors = require('./errors');
|
||||||
|
@ -28,6 +27,7 @@ internals.defaults = {
|
||||||
|
|
||||||
|
|
||||||
internals.checkOptions = function (options) {
|
internals.checkOptions = function (options) {
|
||||||
|
|
||||||
var optionType = {
|
var optionType = {
|
||||||
abortEarly: 'boolean',
|
abortEarly: 'boolean',
|
||||||
convert: 'boolean',
|
convert: 'boolean',
|
||||||
|
@ -64,6 +64,8 @@ internals.checkOptions = function (options) {
|
||||||
|
|
||||||
module.exports = internals.Any = function () {
|
module.exports = internals.Any = function () {
|
||||||
|
|
||||||
|
Cast = Cast || require('./cast');
|
||||||
|
|
||||||
this.isJoi = true;
|
this.isJoi = true;
|
||||||
this._type = 'any';
|
this._type = 'any';
|
||||||
this._settings = null;
|
this._settings = null;
|
||||||
|
@ -80,7 +82,8 @@ module.exports = internals.Any = function () {
|
||||||
encoding: undefined,
|
encoding: undefined,
|
||||||
insensitive: false,
|
insensitive: false,
|
||||||
trim: false,
|
trim: false,
|
||||||
case: undefined // upper, lower
|
case: undefined, // upper, lower
|
||||||
|
empty: undefined
|
||||||
*/ };
|
*/ };
|
||||||
|
|
||||||
this._description = null;
|
this._description = null;
|
||||||
|
@ -131,10 +134,23 @@ internals.Any.prototype.clone = function () {
|
||||||
internals.Any.prototype.concat = function (schema) {
|
internals.Any.prototype.concat = function (schema) {
|
||||||
|
|
||||||
Hoek.assert(schema && schema.isJoi, 'Invalid schema object');
|
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();
|
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._settings = obj._settings ? internals.concatSettings(obj._settings, schema._settings) : schema._settings;
|
||||||
obj._valids.merge(schema._valids, schema._invalids);
|
obj._valids.merge(schema._valids, schema._invalids);
|
||||||
obj._invalids.merge(schema._invalids, schema._valids);
|
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) {
|
internals.Any.prototype.when = function (ref, options) {
|
||||||
|
|
||||||
Hoek.assert(options && typeof options === 'object', 'Invalid 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"');
|
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 then = options.then ? this.concat(Cast.schema(options.then)) : this;
|
||||||
var otherwise = options.otherwise ? this.concat(Cast.schema(options.otherwise)) : 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;
|
var presence = this._flags.presence || options.presence;
|
||||||
if (presence === 'optional') {
|
if (presence === 'optional') {
|
||||||
if (value === undefined) {
|
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' &&
|
else if (presence === 'required' &&
|
||||||
|
@ -518,6 +557,11 @@ internals.Any.prototype._validate = function (value, state, options, reference)
|
||||||
return finish();
|
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
|
// Check allowed and denied values using the original value
|
||||||
|
|
||||||
if (this._valids.has(value, state, options, this._flags.insensitive)) {
|
if (this._valids.has(value, state, options, this._flags.insensitive)) {
|
||||||
|
@ -624,8 +668,18 @@ internals.Any.prototype.describe = function () {
|
||||||
type: this._type
|
type: this._type
|
||||||
};
|
};
|
||||||
|
|
||||||
if (Object.keys(this._flags).length) {
|
var flags = Object.keys(this._flags);
|
||||||
description.flags = 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) {
|
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
|
// Return the actual error if only one inclusion defined
|
||||||
if (il === 1) {
|
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));
|
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;
|
errored = true;
|
||||||
|
|
||||||
|
@ -217,6 +217,13 @@ internals.checkItems = function (items, wasArray, state, options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._inner.inclusions.length && !isValid) {
|
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));
|
errors.push(Errors.create(wasArray ? 'array.includes' : 'array.includesSingle', { pos: v, value: item }, { key: state.key, path: localState.path }, options));
|
||||||
|
|
||||||
if (options.abortEarly) {
|
if (options.abortEarly) {
|
||||||
|
@ -226,35 +233,41 @@ internals.checkItems = function (items, wasArray, state, options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (requireds.length) {
|
if (requireds.length) {
|
||||||
var knownMisses = [];
|
internals.fillMissedErrors(errors, requireds, state, options);
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return errors.length ? errors : null;
|
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 () {
|
internals.Array.prototype.describe = function () {
|
||||||
|
|
||||||
var description = Any.prototype.describe.call(this);
|
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.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.invalidDate = new Date('');
|
||||||
internals.isIsoDate = (function() {
|
internals.isIsoDate = (function () {
|
||||||
|
|
||||||
var isoString = internals.isoDate.toString();
|
var isoString = internals.isoDate.toString();
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ internals.compare = function (type, compare) {
|
||||||
compareTo = Date.now();
|
compareTo = Date.now();
|
||||||
}
|
}
|
||||||
else if (isRef) {
|
else if (isRef) {
|
||||||
compareTo = internals.toDate(date(state.parent));
|
compareTo = internals.toDate(date(state.parent, options));
|
||||||
|
|
||||||
if (!compareTo) {
|
if (!compareTo) {
|
||||||
return Errors.create('date.ref', { ref: date.key }, state, options);
|
return Errors.create('date.ref', { ref: date.key }, state, options);
|
||||||
|
|
|
@ -165,46 +165,46 @@ internals.getPath = function (item) {
|
||||||
// Inspired by json-stringify-safe
|
// Inspired by json-stringify-safe
|
||||||
internals.safeStringify = function (obj, spaces) {
|
internals.safeStringify = function (obj, spaces) {
|
||||||
|
|
||||||
return JSON.stringify(obj, internals.serializer(), spaces);
|
return JSON.stringify(obj, internals.serializer(), spaces);
|
||||||
};
|
};
|
||||||
|
|
||||||
internals.serializer = function () {
|
internals.serializer = function () {
|
||||||
|
|
||||||
var cycleReplacer = function (key, value) {
|
var cycleReplacer = function (key, value) {
|
||||||
|
|
||||||
if (stack[0] === value) {
|
if (stack[0] === value) {
|
||||||
return '[Circular ~]';
|
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) {
|
if (stack.length > 0) {
|
||||||
var thisPos = stack.indexOf(this);
|
var thisPos = stack.indexOf(this);
|
||||||
if (~thisPos) {
|
if (~thisPos) {
|
||||||
stack.length = thisPos + 1;
|
stack.length = thisPos + 1;
|
||||||
keys.length = thisPos + 1;
|
keys.length = thisPos + 1;
|
||||||
keys[thisPos] = key;
|
keys[thisPos] = key;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
stack.push(this);
|
stack.push(this);
|
||||||
keys.push(key);
|
keys.push(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (~stack.indexOf(value)) {
|
if (~stack.indexOf(value)) {
|
||||||
value = cycleReplacer.call(this, key, value);
|
value = cycleReplacer.call(this, key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
stack.push(value);
|
stack.push(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ internals.compare = function (type, compare) {
|
||||||
|
|
||||||
var compareTo;
|
var compareTo;
|
||||||
if (isRef) {
|
if (isRef) {
|
||||||
compareTo = limit(state.parent);
|
compareTo = limit(state.parent, options);
|
||||||
|
|
||||||
if (!(typeof compareTo === 'number' && !isNaN(compareTo))) {
|
if (!(typeof compareTo === 'number' && !isNaN(compareTo))) {
|
||||||
return Errors.create('number.ref', { ref: limit.key }, state, options);
|
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) {
|
internals.Object.prototype._base = function (value, state, options) {
|
||||||
|
|
||||||
|
var item, key, localState, result;
|
||||||
var target = value;
|
var target = value;
|
||||||
var errors = [];
|
var errors = [];
|
||||||
var finish = function () {
|
var finish = function () {
|
||||||
|
@ -43,7 +44,7 @@ internals.Object.prototype._base = function (value, state, options) {
|
||||||
try {
|
try {
|
||||||
value = JSON.parse(value);
|
value = JSON.parse(value);
|
||||||
}
|
}
|
||||||
catch (err) { }
|
catch (parseErr) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!value ||
|
if (!value ||
|
||||||
|
@ -82,7 +83,7 @@ internals.Object.prototype._base = function (value, state, options) {
|
||||||
|
|
||||||
var renamed = {};
|
var renamed = {};
|
||||||
for (var r = 0, rl = this._inner.renames.length; r < rl; ++r) {
|
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) {
|
if (item.options.ignoreUndefined && target[item.from] === undefined) {
|
||||||
continue;
|
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
|
// Validate schema
|
||||||
|
|
||||||
if (!this._inner.children && // null allows any keys
|
if (!this._inner.children && // null allows any keys
|
||||||
!this._inner.patterns.length) {
|
!this._inner.patterns.length &&
|
||||||
|
!this._inner.dependencies.length) {
|
||||||
|
|
||||||
return finish();
|
return finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
var unprocessed = Hoek.mapToObject(Object.keys(target));
|
var unprocessed = Hoek.mapToObject(Object.keys(target));
|
||||||
var key;
|
|
||||||
|
|
||||||
if (this._inner.children) {
|
if (this._inner.children) {
|
||||||
for (var i = 0, il = this._inner.children.length; i < il; ++i) {
|
for (var i = 0, il = this._inner.children.length; i < il; ++i) {
|
||||||
var child = this._inner.children[i];
|
var child = this._inner.children[i];
|
||||||
var key = child.key;
|
key = child.key;
|
||||||
var item = target[key];
|
item = target[key];
|
||||||
|
|
||||||
delete unprocessed[key];
|
delete unprocessed[key];
|
||||||
|
|
||||||
var localState = { key: key, path: (state.path ? state.path + '.' : '') + key, parent: target, reference: state.reference };
|
localState = { key: key, path: (state.path ? state.path + '.' : '') + key, parent: target, reference: state.reference };
|
||||||
var result = child.schema._validate(item, localState, options);
|
result = child.schema._validate(item, localState, options);
|
||||||
if (result.errors) {
|
if (result.errors) {
|
||||||
errors.push(Errors.create('object.child', { key: key, reason: result.errors }, localState, options));
|
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) {
|
this._inner.patterns.length) {
|
||||||
|
|
||||||
for (i = 0, il = unprocessedKeys.length; i < il; ++i) {
|
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) {
|
for (var p = 0, pl = this._inner.patterns.length; p < pl; ++p) {
|
||||||
var pattern = this._inner.patterns[p];
|
var pattern = this._inner.patterns[p];
|
||||||
|
@ -187,9 +175,9 @@ internals.Object.prototype._base = function (value, state, options) {
|
||||||
if (pattern.regex.test(key)) {
|
if (pattern.regex.test(key)) {
|
||||||
delete unprocessed[key];
|
delete unprocessed[key];
|
||||||
|
|
||||||
var item = target[key];
|
item = target[key];
|
||||||
var localState = { key: key, path: (state.path ? state.path + '.' : '') + key, parent: target, reference: state.reference };
|
localState = { key: key, path: (state.path ? state.path + '.' : '') + key, parent: target, reference: state.reference };
|
||||||
var result = pattern.rule._validate(item, localState, options);
|
result = pattern.rule._validate(item, localState, options);
|
||||||
if (result.errors) {
|
if (result.errors) {
|
||||||
errors.push(Errors.create('object.child', { key: key, reason: result.errors }, localState, options));
|
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);
|
unprocessedKeys = Object.keys(unprocessed);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unprocessedKeys.length) {
|
if ((this._inner.children || this._inner.patterns.length) && unprocessedKeys.length) {
|
||||||
if (options.stripUnknown ||
|
if (options.stripUnknown ||
|
||||||
options.skipFunctions) {
|
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();
|
return finish();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -267,16 +268,17 @@ internals.Object.prototype.keys = function (schema) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var topo = new Topo();
|
var topo = new Topo();
|
||||||
|
var child;
|
||||||
if (obj._inner.children) {
|
if (obj._inner.children) {
|
||||||
for (var i = 0, il = obj._inner.children.length; i < il; ++i) {
|
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 });
|
topo.add(child, { after: child._refs, group: child.key });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var c = 0, cl = children.length; c < cl; ++c) {
|
for (var c = 0, cl = children.length; c < cl; ++c) {
|
||||||
var key = children[c];
|
var key = children[c];
|
||||||
var child = schema[key];
|
child = schema[key];
|
||||||
var cast = Cast.schema(child);
|
var cast = Cast.schema(child);
|
||||||
topo.add({ key: key, schema: cast }, { after: cast._refs, group: key });
|
topo.add({ key: key, schema: cast }, { after: cast._refs, group: key });
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ internals.compare = function (type, compare) {
|
||||||
|
|
||||||
var compareTo;
|
var compareTo;
|
||||||
if (isRef) {
|
if (isRef) {
|
||||||
compareTo = limit(state.parent);
|
compareTo = limit(state.parent, options);
|
||||||
|
|
||||||
if (!Hoek.isInteger(compareTo)) {
|
if (!Hoek.isInteger(compareTo)) {
|
||||||
return Errors.create('string.ref', { ref: limit.key }, state, options);
|
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;
|
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)) {
|
if (regex.test(value)) {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -15,7 +15,7 @@ var internals = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
internals.Ip.createIpRegex = function(versions, cidr) {
|
internals.Ip.createIpRegex = function (versions, cidr) {
|
||||||
|
|
||||||
var regex;
|
var regex;
|
||||||
for (var i = 0, il = versions.length; i < il; ++i) {
|
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")
|
* [clone](#cloneobj "clone")
|
||||||
* [cloneWithShallow](#clonewithshallowobj-keys "cloneWithShallow")
|
* [cloneWithShallow](#clonewithshallowobj-keys "cloneWithShallow")
|
||||||
* [merge](#mergetarget-source-isnulloverride-ismergearrays "merge")
|
* [merge](#mergetarget-source-isnulloverride-ismergearrays "merge")
|
||||||
* [applyToDefaults](#applytodefaultsdefaults-options "applyToDefaults")
|
* [applyToDefaults](#applytodefaultsdefaults-options-isnulloverride "applyToDefaults")
|
||||||
* [applyToDefaultsWithShallow](#applytodefaultswithshallowdefaults-options-keys "applyToDefaultsWithShallow")
|
* [applyToDefaultsWithShallow](#applytodefaultswithshallowdefaults-options-keys "applyToDefaultsWithShallow")
|
||||||
* [deepEqual](#deepequala-b "deepEqual")
|
* [deepEqual](#deepequala-b "deepEqual")
|
||||||
* [unique](#uniquearray-key "unique")
|
* [unique](#uniquearray-key "unique")
|
||||||
|
@ -22,6 +22,7 @@ Lead Maintainer: [Nathan LaFreniere](https://github.com/nlf)
|
||||||
* [contain](#containref-values-options "contain")
|
* [contain](#containref-values-options "contain")
|
||||||
* [flatten](#flattenarray-target "flatten")
|
* [flatten](#flattenarray-target "flatten")
|
||||||
* [reach](#reachobj-chain-options "reach")
|
* [reach](#reachobj-chain-options "reach")
|
||||||
|
* [reachTemplate](#reachobj-template-options "reachTemplate")
|
||||||
* [transform](#transformobj-transform-options "transform")
|
* [transform](#transformobj-transform-options "transform")
|
||||||
* [shallow](#shallowobj "shallow")
|
* [shallow](#shallowobj "shallow")
|
||||||
* [stringify](#stringifyobj "stringify")
|
* [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]
|
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
|
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 }
|
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)
|
### applyToDefaultsWithShallow(defaults, options, keys)
|
||||||
keys is an array of key names to shallow copy
|
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
|
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])
|
### 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.
|
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 {
|
else {
|
||||||
var proto = Object.getPrototypeOf(obj);
|
var proto = Object.getPrototypeOf(obj);
|
||||||
if (!proto || proto.isImmutable) {
|
if (proto &&
|
||||||
|
proto.isImmutable) {
|
||||||
|
|
||||||
newObj = obj;
|
newObj = obj;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -142,7 +144,7 @@ exports.merge = function (target, source, isNullOverride /* = true */, isMergeAr
|
||||||
|
|
||||||
// Apply options to a copy of the defaults
|
// 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(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');
|
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 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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj.length !== ref.length) {
|
if (!options.part && obj.length !== ref.length) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0, il = obj.length; i < il; ++i) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -327,7 +341,7 @@ exports.deepEqual = function (obj, ref, options, seen) {
|
||||||
|
|
||||||
var keys = Object.getOwnPropertyNames(obj);
|
var keys = Object.getOwnPropertyNames(obj);
|
||||||
|
|
||||||
if (keys.length !== Object.getOwnPropertyNames(ref).length) {
|
if (!options.part && keys.length !== Object.getOwnPropertyNames(ref).length) {
|
||||||
return false;
|
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(typeof ref === 'string' || typeof ref === 'object', 'Reference must be string or an object');
|
||||||
exports.assert(values.length, 'Values array cannot be empty');
|
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 misses = false;
|
||||||
var matches = new Array(values.length);
|
var matches = new Array(values.length);
|
||||||
|
@ -477,7 +507,7 @@ exports.contain = function (ref, values, options) {
|
||||||
else if (Array.isArray(ref)) {
|
else if (Array.isArray(ref)) {
|
||||||
for (i = 0, il = ref.length; i < il; ++i) {
|
for (i = 0, il = ref.length; i < il; ++i) {
|
||||||
for (var j = 0, jl = values.length, matched = false; j < jl && matched === false; ++j) {
|
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) {
|
if (matched !== false) {
|
||||||
|
@ -495,7 +525,7 @@ exports.contain = function (ref, values, options) {
|
||||||
var pos = values.indexOf(key);
|
var pos = values.indexOf(key);
|
||||||
if (pos !== -1) {
|
if (pos !== -1) {
|
||||||
if (valuePairs &&
|
if (valuePairs &&
|
||||||
!compare(ref[key], valuePairs[key])) {
|
!compare(valuePairs[key], ref[key], compareFlags)) {
|
||||||
|
|
||||||
return false;
|
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) {
|
exports.formatStack = function (stack) {
|
||||||
|
|
||||||
var trace = [];
|
var trace = [];
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
{
|
{
|
||||||
"name": "hoek",
|
"name": "hoek",
|
||||||
"description": "General purpose node utilities",
|
"description": "General purpose node utilities",
|
||||||
"version": "2.12.0",
|
"version": "2.14.0",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git://github.com/hapijs/hoek"
|
"url": "git://github.com/hapijs/hoek.git"
|
||||||
},
|
},
|
||||||
"main": "index",
|
"main": "index",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
@ -21,26 +21,25 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "make test-cov"
|
"test": "make test-cov"
|
||||||
},
|
},
|
||||||
"licenses": [
|
"license": "BSD-3-Clause",
|
||||||
{
|
"gitHead": "e80875a516f4b0eaa757ac4814c4510eebdcf589",
|
||||||
"type": "BSD",
|
|
||||||
"url": "http://github.com/hapijs/hoek/raw/master/LICENSE"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"gitHead": "9bbb8f149b5b824f66b47ae4cf3afb1e2877396f",
|
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/hapijs/hoek/issues"
|
"url": "https://github.com/hapijs/hoek/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/hapijs/hoek",
|
"homepage": "https://github.com/hapijs/hoek#readme",
|
||||||
"_id": "hoek@2.12.0",
|
"_id": "hoek@2.14.0",
|
||||||
"_shasum": "5d1196e0bf20c5cec957e8927101164effdaf1c9",
|
"_shasum": "81211691f52a5a835ae49edbf1e89c9003476aa4",
|
||||||
"_from": "hoek@>=2.2.0 <3.0.0",
|
"_from": "hoek@>=2.2.0 <3.0.0",
|
||||||
"_npmVersion": "2.6.1",
|
"_npmVersion": "2.9.0",
|
||||||
"_nodeVersion": "0.10.36",
|
"_nodeVersion": "0.12.2",
|
||||||
"_npmUser": {
|
"_npmUser": {
|
||||||
"name": "nlf",
|
"name": "nlf",
|
||||||
"email": "quitlahok@gmail.com"
|
"email": "quitlahok@gmail.com"
|
||||||
},
|
},
|
||||||
|
"dist": {
|
||||||
|
"shasum": "81211691f52a5a835ae49edbf1e89c9003476aa4",
|
||||||
|
"tarball": "http://registry.npmjs.org/hoek/-/hoek-2.14.0.tgz"
|
||||||
|
},
|
||||||
"maintainers": [
|
"maintainers": [
|
||||||
{
|
{
|
||||||
"name": "hueniverse",
|
"name": "hueniverse",
|
||||||
|
@ -55,11 +54,7 @@
|
||||||
"email": "quitlahok@gmail.com"
|
"email": "quitlahok@gmail.com"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"dist": {
|
|
||||||
"shasum": "5d1196e0bf20c5cec957e8927101164effdaf1c9",
|
|
||||||
"tarball": "http://registry.npmjs.org/hoek/-/hoek-2.12.0.tgz"
|
|
||||||
},
|
|
||||||
"directories": {},
|
"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!"
|
"readme": "ERROR: No README data found!"
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -12,7 +12,7 @@
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"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",
|
"homepage": "https://github.com/globesherpa/node-isemail",
|
||||||
"bugs": {
|
"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
|
Permission is hereby granted, free of charge, to any person
|
||||||
obtaining a copy of this software and associated documentation
|
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]
|
[![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.
|
A lightweight JavaScript date library for parsing, validating, manipulating, and formatting dates.
|
||||||
|
|
|
@ -75,7 +75,7 @@
|
||||||
longDateFormat : {
|
longDateFormat : {
|
||||||
LT : 'HH:mm',
|
LT : 'HH:mm',
|
||||||
LTS : 'HH:mm:ss',
|
LTS : 'HH:mm:ss',
|
||||||
L : 'DD/MM/YYYY',
|
L : 'D/\u200FM/\u200FYYYY',
|
||||||
LL : 'D MMMM YYYY',
|
LL : 'D MMMM YYYY',
|
||||||
LLL : 'D MMMM YYYY LT',
|
LLL : 'D MMMM YYYY LT',
|
||||||
LLLL : 'dddd D MMMM YYYY LT'
|
LLLL : 'dddd D MMMM YYYY LT'
|
||||||
|
@ -115,7 +115,7 @@
|
||||||
yy : pluralize('y')
|
yy : pluralize('y')
|
||||||
},
|
},
|
||||||
preparse: function (string) {
|
preparse: function (string) {
|
||||||
return string.replace(/[١٢٣٤٥٦٧٨٩٠]/g, function (match) {
|
return string.replace(/\u200f/g, '').replace(/[١٢٣٤٥٦٧٨٩٠]/g, function (match) {
|
||||||
return numberMap[match];
|
return numberMap[match];
|
||||||
}).replace(/،/g, ',');
|
}).replace(/،/g, ',');
|
||||||
},
|
},
|
||||||
|
|
|
@ -10,47 +10,47 @@
|
||||||
|
|
||||||
|
|
||||||
var cv = moment.defineLocale('cv', {
|
var cv = moment.defineLocale('cv', {
|
||||||
months : 'кăрлач_нарăс_пуш_ака_май_çĕртме_утă_çурла_авăн_юпа_чӳк_раштав'.split('_'),
|
months : 'кӑрлач_нарӑс_пуш_ака_май_ҫӗртме_утӑ_ҫурла_авӑн_юпа_чӳк_раштав'.split('_'),
|
||||||
monthsShort : 'кăр_нар_пуш_ака_май_çĕр_утă_çур_ав_юпа_чӳк_раш'.split('_'),
|
monthsShort : 'кӑр_нар_пуш_ака_май_ҫӗр_утӑ_ҫур_авн_юпа_чӳк_раш'.split('_'),
|
||||||
weekdays : 'вырсарникун_тунтикун_ытларикун_юнкун_кĕçнерникун_эрнекун_шăматкун'.split('_'),
|
weekdays : 'вырсарникун_тунтикун_ытларикун_юнкун_кӗҫнерникун_эрнекун_шӑматкун'.split('_'),
|
||||||
weekdaysShort : 'выр_тун_ытл_юн_кĕç_эрн_шăм'.split('_'),
|
weekdaysShort : 'выр_тун_ытл_юн_кӗҫ_эрн_шӑм'.split('_'),
|
||||||
weekdaysMin : 'вр_тн_ыт_юн_кç_эр_шм'.split('_'),
|
weekdaysMin : 'вр_тн_ыт_юн_кҫ_эр_шм'.split('_'),
|
||||||
longDateFormat : {
|
longDateFormat : {
|
||||||
LT : 'HH:mm',
|
LT : 'HH:mm',
|
||||||
LTS : 'LT:ss',
|
LTS : 'LT:ss',
|
||||||
L : 'DD-MM-YYYY',
|
L : 'DD-MM-YYYY',
|
||||||
LL : 'YYYY [çулхи] MMMM [уйăхĕн] D[-мĕшĕ]',
|
LL : 'YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ]',
|
||||||
LLL : 'YYYY [çулхи] MMMM [уйăхĕн] D[-мĕшĕ], LT',
|
LLL : 'YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ], LT',
|
||||||
LLLL : 'dddd, YYYY [çулхи] MMMM [уйăхĕн] D[-мĕшĕ], LT'
|
LLLL : 'dddd, YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ], LT'
|
||||||
},
|
},
|
||||||
calendar : {
|
calendar : {
|
||||||
sameDay: '[Паян] LT [сехетре]',
|
sameDay: '[Паян] LT [сехетре]',
|
||||||
nextDay: '[Ыран] LT [сехетре]',
|
nextDay: '[Ыран] LT [сехетре]',
|
||||||
lastDay: '[Ĕнер] LT [сехетре]',
|
lastDay: '[Ӗнер] LT [сехетре]',
|
||||||
nextWeek: '[Çитес] dddd LT [сехетре]',
|
nextWeek: '[Ҫитес] dddd LT [сехетре]',
|
||||||
lastWeek: '[Иртнĕ] dddd LT [сехетре]',
|
lastWeek: '[Иртнӗ] dddd LT [сехетре]',
|
||||||
sameElse: 'L'
|
sameElse: 'L'
|
||||||
},
|
},
|
||||||
relativeTime : {
|
relativeTime : {
|
||||||
future : function (output) {
|
future : function (output) {
|
||||||
var affix = /сехет$/i.exec(output) ? 'рен' : /çул$/i.exec(output) ? 'тан' : 'ран';
|
var affix = /сехет$/i.exec(output) ? 'рен' : /ҫул$/i.exec(output) ? 'тан' : 'ран';
|
||||||
return output + affix;
|
return output + affix;
|
||||||
},
|
},
|
||||||
past : '%s каялла',
|
past : '%s каялла',
|
||||||
s : 'пĕр-ик çеккунт',
|
s : 'пӗр-ик ҫеккунт',
|
||||||
m : 'пĕр минут',
|
m : 'пӗр минут',
|
||||||
mm : '%d минут',
|
mm : '%d минут',
|
||||||
h : 'пĕр сехет',
|
h : 'пӗр сехет',
|
||||||
hh : '%d сехет',
|
hh : '%d сехет',
|
||||||
d : 'пĕр кун',
|
d : 'пӗр кун',
|
||||||
dd : '%d кун',
|
dd : '%d кун',
|
||||||
M : 'пĕр уйăх',
|
M : 'пӗр уйӑх',
|
||||||
MM : '%d уйăх',
|
MM : '%d уйӑх',
|
||||||
y : 'пĕр çул',
|
y : 'пӗр ҫул',
|
||||||
yy : '%d çул'
|
yy : '%d ҫул'
|
||||||
},
|
},
|
||||||
ordinalParse: /\d{1,2}-мĕш/,
|
ordinalParse: /\d{1,2}-мӗш/,
|
||||||
ordinal : '%d-мĕш',
|
ordinal : '%d-мӗш',
|
||||||
week : {
|
week : {
|
||||||
dow : 1, // Monday is the first day of the 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.
|
doy : 7 // The week that contains Jan 1st is the first week of the year.
|
||||||
|
|
|
@ -9,11 +9,11 @@
|
||||||
}(this, function (moment) { 'use strict';
|
}(this, function (moment) { 'use strict';
|
||||||
|
|
||||||
|
|
||||||
var monthsShortDot = '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('_');
|
monthsShort = 'Ene_Feb_Mar_Abr_May_Jun_Jul_Ago_Sep_Oct_Nov_Dic'.split('_');
|
||||||
|
|
||||||
var es = moment.defineLocale('es', {
|
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) {
|
monthsShort : function (m, format) {
|
||||||
if (/-MMM-/.test(format)) {
|
if (/-MMM-/.test(format)) {
|
||||||
return monthsShort[m.month()];
|
return monthsShort[m.month()];
|
||||||
|
@ -21,8 +21,8 @@
|
||||||
return monthsShortDot[m.month()];
|
return monthsShortDot[m.month()];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
weekdays : 'domingo_lunes_martes_miércoles_jueves_viernes_sábado'.split('_'),
|
weekdays : 'Domingo_Lunes_Martes_Miércoles_Jueves_Viernes_Sábado'.split('_'),
|
||||||
weekdaysShort : 'dom._lun._mar._mié._jue._vie._sáb.'.split('_'),
|
weekdaysShort : 'Dom._Lun._Mar._Mié._Jue._Vie._Sáb.'.split('_'),
|
||||||
weekdaysMin : 'Do_Lu_Ma_Mi_Ju_Vi_Sá'.split('_'),
|
weekdaysMin : 'Do_Lu_Ma_Mi_Ju_Vi_Sá'.split('_'),
|
||||||
longDateFormat : {
|
longDateFormat : {
|
||||||
LT : 'H:mm',
|
LT : 'H:mm',
|
||||||
|
|
|
@ -63,8 +63,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
var hr = moment.defineLocale('hr', {
|
var hr = moment.defineLocale('hr', {
|
||||||
months : 'sječanj_veljača_ožujak_travanj_svibanj_lipanj_srpanj_kolovoz_rujan_listopad_studeni_prosinac'.split('_'),
|
months : 'siječ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('_'),
|
monthsShort : 'sij._velj._ožu._tra._svi._lip._srp._kol._ruj._lis._stu._pro.'.split('_'),
|
||||||
weekdays : 'nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota'.split('_'),
|
weekdays : 'nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota'.split('_'),
|
||||||
weekdaysShort : 'ned._pon._uto._sri._čet._pet._sub.'.split('_'),
|
weekdaysShort : 'ned._pon._uto._sri._čet._pet._sub.'.split('_'),
|
||||||
weekdaysMin : 'ne_po_ut_sr_če_pe_su'.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
|
//! moment.js locale configuration
|
||||||
//! locale : latvian (lv)
|
//! locale : latvian (lv)
|
||||||
//! author : Kristaps Karlsons : https://github.com/skakri
|
//! author : Kristaps Karlsons : https://github.com/skakri
|
||||||
|
//! author : Jānis Elmeris : https://github.com/JanisE
|
||||||
|
|
||||||
(function (global, factory) {
|
(function (global, factory) {
|
||||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../moment')) :
|
||||||
|
@ -10,23 +11,39 @@
|
||||||
|
|
||||||
|
|
||||||
var units = {
|
var units = {
|
||||||
'mm': 'minūti_minūtes_minūte_minūtes',
|
'm': 'minūtes_minūtēm_minūte_minūtes'.split('_'),
|
||||||
'hh': 'stundu_stundas_stunda_stundas',
|
'mm': 'minūtes_minūtēm_minūte_minūtes'.split('_'),
|
||||||
'dd': 'dienu_dienas_diena_dienas',
|
'h': 'stundas_stundām_stunda_stundas'.split('_'),
|
||||||
'MM': 'mēnesi_mēnešus_mēnesis_mēneši',
|
'hh': 'stundas_stundām_stunda_stundas'.split('_'),
|
||||||
'yy': 'gadu_gadus_gads_gadi'
|
'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) {
|
if (withoutSuffix) {
|
||||||
|
// E.g. "21 minūte", "3 minūtes".
|
||||||
return number % 10 === 1 && number !== 11 ? forms[2] : forms[3];
|
return number % 10 === 1 && number !== 11 ? forms[2] : forms[3];
|
||||||
} else {
|
} 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];
|
return number % 10 === 1 && number !== 11 ? forms[0] : forms[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function relativeTimeWithPlural(number, withoutSuffix, key) {
|
function relativeTimeWithPlural(number, withoutSuffix, key) {
|
||||||
return number + ' ' + format(units[key], number, withoutSuffix);
|
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', {
|
var lv = moment.defineLocale('lv', {
|
||||||
months : 'janvāris_februāris_marts_aprīlis_maijs_jūnijs_jūlijs_augusts_septembris_oktobris_novembris_decembris'.split('_'),
|
months : 'janvāris_februāris_marts_aprīlis_maijs_jūnijs_jūlijs_augusts_septembris_oktobris_novembris_decembris'.split('_'),
|
||||||
|
@ -37,7 +54,7 @@
|
||||||
longDateFormat : {
|
longDateFormat : {
|
||||||
LT : 'HH:mm',
|
LT : 'HH:mm',
|
||||||
LTS : 'LT:ss',
|
LTS : 'LT:ss',
|
||||||
L : 'DD.MM.YYYY',
|
L : 'DD.MM.YYYY.',
|
||||||
LL : 'YYYY. [gada] D. MMMM',
|
LL : 'YYYY. [gada] D. MMMM',
|
||||||
LLL : 'YYYY. [gada] D. MMMM, LT',
|
LLL : 'YYYY. [gada] D. MMMM, LT',
|
||||||
LLLL : 'YYYY. [gada] D. MMMM, dddd, LT'
|
LLLL : 'YYYY. [gada] D. MMMM, dddd, LT'
|
||||||
|
@ -51,18 +68,18 @@
|
||||||
sameElse : 'L'
|
sameElse : 'L'
|
||||||
},
|
},
|
||||||
relativeTime : {
|
relativeTime : {
|
||||||
future : '%s vēlāk',
|
future : 'pēc %s',
|
||||||
past : '%s agrāk',
|
past : 'pirms %s',
|
||||||
s : 'dažas sekundes',
|
s : relativeSeconds,
|
||||||
m : 'minūti',
|
m : relativeTimeWithSingular,
|
||||||
mm : relativeTimeWithPlural,
|
mm : relativeTimeWithPlural,
|
||||||
h : 'stundu',
|
h : relativeTimeWithSingular,
|
||||||
hh : relativeTimeWithPlural,
|
hh : relativeTimeWithPlural,
|
||||||
d : 'dienu',
|
d : relativeTimeWithSingular,
|
||||||
dd : relativeTimeWithPlural,
|
dd : relativeTimeWithPlural,
|
||||||
M : 'mēnesi',
|
M : relativeTimeWithSingular,
|
||||||
MM : relativeTimeWithPlural,
|
MM : relativeTimeWithPlural,
|
||||||
y : 'gadu',
|
y : relativeTimeWithSingular,
|
||||||
yy : relativeTimeWithPlural
|
yy : relativeTimeWithPlural
|
||||||
},
|
},
|
||||||
ordinalParse: /\d{1,2}\./,
|
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('_'),
|
months: 'ဇန်နဝါရီ_ဖေဖော်ဝါရီ_မတ်_ဧပြီ_မေ_ဇွန်_ဇူလိုင်_သြဂုတ်_စက်တင်ဘာ_အောက်တိုဘာ_နိုဝင်ဘာ_ဒီဇင်ဘာ'.split('_'),
|
||||||
monthsShort: 'ဇန်_ဖေ_မတ်_ပြီ_မေ_ဇွန်_လိုင်_သြ_စက်_အောက်_နို_ဒီ'.split('_'),
|
monthsShort: 'ဇန်_ဖေ_မတ်_ပြီ_မေ_ဇွန်_လိုင်_သြ_စက်_အောက်_နို_ဒီ'.split('_'),
|
||||||
weekdays: 'တနင်္ဂနွေ_တနင်္လာ_အင်္ဂါ_ဗုဒ္ဓဟူး_ကြာသပတေး_သောကြာ_စနေ'.split('_'),
|
weekdays: 'တနင်္ဂနွေ_တနင်္လာ_အင်္ဂါ_ဗုဒ္ဓဟူး_ကြာသပတေး_သောကြာ_စနေ'.split('_'),
|
||||||
weekdaysShort: 'နွေ_လာ_င်္ဂါ_ဟူး_ကြာ_သော_နေ'.split('_'),
|
weekdaysShort: 'နွေ_လာ_ဂါ_ဟူး_ကြာ_သော_နေ'.split('_'),
|
||||||
weekdaysMin: 'နွေ_လာ_င်္ဂါ_ဟူး_ကြာ_သော_နေ'.split('_'),
|
weekdaysMin: 'နွေ_လာ_ဂါ_ဟူး_ကြာ_သော_နေ'.split('_'),
|
||||||
|
|
||||||
longDateFormat: {
|
longDateFormat: {
|
||||||
LT: 'HH:mm',
|
LT: 'HH:mm',
|
||||||
LTS: 'HH:mm:ss',
|
LTS: 'HH:mm:ss',
|
||||||
|
|
|
@ -34,7 +34,12 @@
|
||||||
|
|
||||||
var pl = moment.defineLocale('pl', {
|
var pl = moment.defineLocale('pl', {
|
||||||
months : function (momentToFormat, format) {
|
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()];
|
return monthsSubjective[momentToFormat.month()];
|
||||||
} else {
|
} else {
|
||||||
return monthsNominative[momentToFormat.month()];
|
return monthsNominative[momentToFormat.month()];
|
||||||
|
|
|
@ -10,11 +10,11 @@
|
||||||
|
|
||||||
|
|
||||||
var pt_br = moment.defineLocale('pt-br', {
|
var pt_br = moment.defineLocale('pt-br', {
|
||||||
months : 'janeiro_fevereiro_março_abril_maio_junho_julho_agosto_setembro_outubro_novembro_dezembro'.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('_'),
|
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('_'),
|
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('_'),
|
weekdaysShort : 'Dom_Seg_Ter_Qua_Qui_Sex_Sáb'.split('_'),
|
||||||
weekdaysMin : 'dom_2ª_3ª_4ª_5ª_6ª_sáb'.split('_'),
|
weekdaysMin : 'Dom_2ª_3ª_4ª_5ª_6ª_Sáb'.split('_'),
|
||||||
longDateFormat : {
|
longDateFormat : {
|
||||||
LT : 'HH:mm',
|
LT : 'HH:mm',
|
||||||
LTS : 'LT:ss',
|
LTS : 'LT:ss',
|
||||||
|
|
|
@ -10,11 +10,11 @@
|
||||||
|
|
||||||
|
|
||||||
var pt = moment.defineLocale('pt', {
|
var pt = moment.defineLocale('pt', {
|
||||||
months : 'janeiro_fevereiro_março_abril_maio_junho_julho_agosto_setembro_outubro_novembro_dezembro'.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('_'),
|
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('_'),
|
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('_'),
|
weekdaysShort : 'Dom_Seg_Ter_Qua_Qui_Sex_Sáb'.split('_'),
|
||||||
weekdaysMin : 'dom_2ª_3ª_4ª_5ª_6ª_sáb'.split('_'),
|
weekdaysMin : 'Dom_2ª_3ª_4ª_5ª_6ª_Sáb'.split('_'),
|
||||||
longDateFormat : {
|
longDateFormat : {
|
||||||
LT : 'HH:mm',
|
LT : 'HH:mm',
|
||||||
LTS : 'LT:ss',
|
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';
|
}(this, function (moment) { 'use strict';
|
||||||
|
|
||||||
|
|
||||||
function translate(number, withoutSuffix, key) {
|
function processRelativeTime(number, withoutSuffix, key, isFuture) {
|
||||||
var result = number + ' ';
|
var result = number + ' ';
|
||||||
switch (key) {
|
switch (key) {
|
||||||
|
case 's':
|
||||||
|
return withoutSuffix || isFuture ? 'nekaj sekund' : 'nekaj sekundami';
|
||||||
case 'm':
|
case 'm':
|
||||||
return withoutSuffix ? 'ena minuta' : 'eno minuto';
|
return withoutSuffix ? 'ena minuta' : 'eno minuto';
|
||||||
case 'mm':
|
case 'mm':
|
||||||
if (number === 1) {
|
if (number === 1) {
|
||||||
result += 'minuta';
|
result += withoutSuffix ? 'minuta' : 'minuto';
|
||||||
} else if (number === 2) {
|
} else if (number === 2) {
|
||||||
result += 'minuti';
|
result += withoutSuffix || isFuture ? 'minuti' : 'minutama';
|
||||||
} else if (number === 3 || number === 4) {
|
} else if (number < 5) {
|
||||||
result += 'minute';
|
result += withoutSuffix || isFuture ? 'minute' : 'minutami';
|
||||||
} else {
|
} else {
|
||||||
result += 'minut';
|
result += withoutSuffix || isFuture ? 'minut' : 'minutami';
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
case 'h':
|
case 'h':
|
||||||
return withoutSuffix ? 'ena ura' : 'eno uro';
|
return withoutSuffix ? 'ena ura' : 'eno uro';
|
||||||
case 'hh':
|
case 'hh':
|
||||||
if (number === 1) {
|
if (number === 1) {
|
||||||
result += 'ura';
|
result += withoutSuffix ? 'ura' : 'uro';
|
||||||
} else if (number === 2) {
|
} else if (number === 2) {
|
||||||
result += 'uri';
|
result += withoutSuffix || isFuture ? 'uri' : 'urama';
|
||||||
} else if (number === 3 || number === 4) {
|
} else if (number < 5) {
|
||||||
result += 'ure';
|
result += withoutSuffix || isFuture ? 'ure' : 'urami';
|
||||||
} else {
|
} else {
|
||||||
result += 'ur';
|
result += withoutSuffix || isFuture ? 'ur' : 'urami';
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
case 'd':
|
||||||
|
return withoutSuffix || isFuture ? 'en dan' : 'enim dnem';
|
||||||
case 'dd':
|
case 'dd':
|
||||||
if (number === 1) {
|
if (number === 1) {
|
||||||
result += 'dan';
|
result += withoutSuffix || isFuture ? 'dan' : 'dnem';
|
||||||
|
} else if (number === 2) {
|
||||||
|
result += withoutSuffix || isFuture ? 'dni' : 'dnevoma';
|
||||||
} else {
|
} else {
|
||||||
result += 'dni';
|
result += withoutSuffix || isFuture ? 'dni' : 'dnevi';
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
case 'M':
|
||||||
|
return withoutSuffix || isFuture ? 'en mesec' : 'enim mesecem';
|
||||||
case 'MM':
|
case 'MM':
|
||||||
if (number === 1) {
|
if (number === 1) {
|
||||||
result += 'mesec';
|
result += withoutSuffix || isFuture ? 'mesec' : 'mesecem';
|
||||||
} else if (number === 2) {
|
} else if (number === 2) {
|
||||||
result += 'meseca';
|
result += withoutSuffix || isFuture ? 'meseca' : 'mesecema';
|
||||||
} else if (number === 3 || number === 4) {
|
} else if (number < 5) {
|
||||||
result += 'mesece';
|
result += withoutSuffix || isFuture ? 'mesece' : 'meseci';
|
||||||
} else {
|
} else {
|
||||||
result += 'mesecev';
|
result += withoutSuffix || isFuture ? 'mesecev' : 'meseci';
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
case 'y':
|
||||||
|
return withoutSuffix || isFuture ? 'eno leto' : 'enim letom';
|
||||||
case 'yy':
|
case 'yy':
|
||||||
if (number === 1) {
|
if (number === 1) {
|
||||||
result += 'leto';
|
result += withoutSuffix || isFuture ? 'leto' : 'letom';
|
||||||
} else if (number === 2) {
|
} else if (number === 2) {
|
||||||
result += 'leti';
|
result += withoutSuffix || isFuture ? 'leti' : 'letoma';
|
||||||
} else if (number === 3 || number === 4) {
|
} else if (number < 5) {
|
||||||
result += 'leta';
|
result += withoutSuffix || isFuture ? 'leta' : 'leti';
|
||||||
} else {
|
} else {
|
||||||
result += 'let';
|
result += withoutSuffix || isFuture ? 'let' : 'leti';
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -87,6 +97,7 @@
|
||||||
calendar : {
|
calendar : {
|
||||||
sameDay : '[danes ob] LT',
|
sameDay : '[danes ob] LT',
|
||||||
nextDay : '[jutri ob] LT',
|
nextDay : '[jutri ob] LT',
|
||||||
|
|
||||||
nextWeek : function () {
|
nextWeek : function () {
|
||||||
switch (this.day()) {
|
switch (this.day()) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -106,9 +117,11 @@
|
||||||
lastWeek : function () {
|
lastWeek : function () {
|
||||||
switch (this.day()) {
|
switch (this.day()) {
|
||||||
case 0:
|
case 0:
|
||||||
|
return '[prejšnjo] [nedeljo] [ob] LT';
|
||||||
case 3:
|
case 3:
|
||||||
|
return '[prejšnjo] [sredo] [ob] LT';
|
||||||
case 6:
|
case 6:
|
||||||
return '[prejšnja] dddd [ob] LT';
|
return '[prejšnjo] [soboto] [ob] LT';
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
case 2:
|
||||||
case 4:
|
case 4:
|
||||||
|
@ -120,18 +133,18 @@
|
||||||
},
|
},
|
||||||
relativeTime : {
|
relativeTime : {
|
||||||
future : 'čez %s',
|
future : 'čez %s',
|
||||||
past : '%s nazaj',
|
past : 'pred %s',
|
||||||
s : 'nekaj sekund',
|
s : processRelativeTime,
|
||||||
m : translate,
|
m : processRelativeTime,
|
||||||
mm : translate,
|
mm : processRelativeTime,
|
||||||
h : translate,
|
h : processRelativeTime,
|
||||||
hh : translate,
|
hh : processRelativeTime,
|
||||||
d : 'en dan',
|
d : processRelativeTime,
|
||||||
dd : translate,
|
dd : processRelativeTime,
|
||||||
M : 'en mesec',
|
M : processRelativeTime,
|
||||||
MM : translate,
|
MM : processRelativeTime,
|
||||||
y : 'eno leto',
|
y : processRelativeTime,
|
||||||
yy : translate
|
yy : processRelativeTime
|
||||||
},
|
},
|
||||||
ordinalParse: /\d{1,2}\./,
|
ordinalParse: /\d{1,2}\./,
|
||||||
ordinal : '%d.',
|
ordinal : '%d.',
|
||||||
|
|
|
@ -27,8 +27,8 @@
|
||||||
sameDay: '[Idag] LT',
|
sameDay: '[Idag] LT',
|
||||||
nextDay: '[Imorgon] LT',
|
nextDay: '[Imorgon] LT',
|
||||||
lastDay: '[Igår] LT',
|
lastDay: '[Igår] LT',
|
||||||
nextWeek: 'dddd LT',
|
nextWeek: '[På] dddd LT',
|
||||||
lastWeek: '[Förra] dddd[en] LT',
|
lastWeek: '[I] dddd[s] LT',
|
||||||
sameElse: 'L'
|
sameElse: 'L'
|
||||||
},
|
},
|
||||||
relativeTime : {
|
relativeTime : {
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
weekdaysShort : '周日_周一_周二_周三_周四_周五_周六'.split('_'),
|
weekdaysShort : '周日_周一_周二_周三_周四_周五_周六'.split('_'),
|
||||||
weekdaysMin : '日_一_二_三_四_五_六'.split('_'),
|
weekdaysMin : '日_一_二_三_四_五_六'.split('_'),
|
||||||
longDateFormat : {
|
longDateFormat : {
|
||||||
LT : 'Ah点mm',
|
LT : 'Ah点mm分',
|
||||||
LTS : 'Ah点m分s秒',
|
LTS : 'Ah点m分s秒',
|
||||||
L : 'YYYY-MM-DD',
|
L : 'YYYY-MM-DD',
|
||||||
LL : 'YYYY年MMMD日',
|
LL : 'YYYY年MMMD日',
|
||||||
|
@ -103,16 +103,16 @@
|
||||||
future : '%s内',
|
future : '%s内',
|
||||||
past : '%s前',
|
past : '%s前',
|
||||||
s : '几秒',
|
s : '几秒',
|
||||||
m : '1分钟',
|
m : '1 分钟',
|
||||||
mm : '%d分钟',
|
mm : '%d 分钟',
|
||||||
h : '1小时',
|
h : '1 小时',
|
||||||
hh : '%d小时',
|
hh : '%d 小时',
|
||||||
d : '1天',
|
d : '1 天',
|
||||||
dd : '%d天',
|
dd : '%d 天',
|
||||||
M : '1个月',
|
M : '1 个月',
|
||||||
MM : '%d个月',
|
MM : '%d 个月',
|
||||||
y : '1年',
|
y : '1 年',
|
||||||
yy : '%d年'
|
yy : '%d 年'
|
||||||
},
|
},
|
||||||
week : {
|
week : {
|
||||||
// GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
|
// GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
weekdaysShort : '週日_週一_週二_週三_週四_週五_週六'.split('_'),
|
weekdaysShort : '週日_週一_週二_週三_週四_週五_週六'.split('_'),
|
||||||
weekdaysMin : '日_一_二_三_四_五_六'.split('_'),
|
weekdaysMin : '日_一_二_三_四_五_六'.split('_'),
|
||||||
longDateFormat : {
|
longDateFormat : {
|
||||||
LT : 'Ah點mm',
|
LT : 'Ah點mm分',
|
||||||
LTS : 'Ah點m分s秒',
|
LTS : 'Ah點m分s秒',
|
||||||
L : 'YYYY年MMMD日',
|
L : 'YYYY年MMMD日',
|
||||||
LL : 'YYYY年MMMD日',
|
LL : 'YYYY年MMMD日',
|
||||||
|
|
|
@ -322,7 +322,7 @@
|
||||||
longDateFormat : {
|
longDateFormat : {
|
||||||
LT : 'HH:mm',
|
LT : 'HH:mm',
|
||||||
LTS : 'HH:mm:ss',
|
LTS : 'HH:mm:ss',
|
||||||
L : 'DD/MM/YYYY',
|
L : 'D/\u200FM/\u200FYYYY',
|
||||||
LL : 'D MMMM YYYY',
|
LL : 'D MMMM YYYY',
|
||||||
LLL : 'D MMMM YYYY LT',
|
LLL : 'D MMMM YYYY LT',
|
||||||
LLLL : 'dddd D MMMM YYYY LT'
|
LLLL : 'dddd D MMMM YYYY LT'
|
||||||
|
@ -362,7 +362,7 @@
|
||||||
yy : pluralize('y')
|
yy : pluralize('y')
|
||||||
},
|
},
|
||||||
preparse: function (string) {
|
preparse: function (string) {
|
||||||
return string.replace(/[١٢٣٤٥٦٧٨٩٠]/g, function (match) {
|
return string.replace(/\u200f/g, '').replace(/[١٢٣٤٥٦٧٨٩٠]/g, function (match) {
|
||||||
return ar__numberMap[match];
|
return ar__numberMap[match];
|
||||||
}).replace(/،/g, ',');
|
}).replace(/،/g, ',');
|
||||||
},
|
},
|
||||||
|
@ -1331,47 +1331,47 @@
|
||||||
//! author : Anatoly Mironov : https://github.com/mirontoli
|
//! author : Anatoly Mironov : https://github.com/mirontoli
|
||||||
|
|
||||||
var cv = moment.defineLocale('cv', {
|
var cv = moment.defineLocale('cv', {
|
||||||
months : 'кăрлач_нарăс_пуш_ака_май_çĕртме_утă_çурла_авăн_юпа_чӳк_раштав'.split('_'),
|
months : 'кӑрлач_нарӑс_пуш_ака_май_ҫӗртме_утӑ_ҫурла_авӑн_юпа_чӳк_раштав'.split('_'),
|
||||||
monthsShort : 'кăр_нар_пуш_ака_май_çĕр_утă_çур_ав_юпа_чӳк_раш'.split('_'),
|
monthsShort : 'кӑр_нар_пуш_ака_май_ҫӗр_утӑ_ҫур_авн_юпа_чӳк_раш'.split('_'),
|
||||||
weekdays : 'вырсарникун_тунтикун_ытларикун_юнкун_кĕçнерникун_эрнекун_шăматкун'.split('_'),
|
weekdays : 'вырсарникун_тунтикун_ытларикун_юнкун_кӗҫнерникун_эрнекун_шӑматкун'.split('_'),
|
||||||
weekdaysShort : 'выр_тун_ытл_юн_кĕç_эрн_шăм'.split('_'),
|
weekdaysShort : 'выр_тун_ытл_юн_кӗҫ_эрн_шӑм'.split('_'),
|
||||||
weekdaysMin : 'вр_тн_ыт_юн_кç_эр_шм'.split('_'),
|
weekdaysMin : 'вр_тн_ыт_юн_кҫ_эр_шм'.split('_'),
|
||||||
longDateFormat : {
|
longDateFormat : {
|
||||||
LT : 'HH:mm',
|
LT : 'HH:mm',
|
||||||
LTS : 'LT:ss',
|
LTS : 'LT:ss',
|
||||||
L : 'DD-MM-YYYY',
|
L : 'DD-MM-YYYY',
|
||||||
LL : 'YYYY [çулхи] MMMM [уйăхĕн] D[-мĕшĕ]',
|
LL : 'YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ]',
|
||||||
LLL : 'YYYY [çулхи] MMMM [уйăхĕн] D[-мĕшĕ], LT',
|
LLL : 'YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ], LT',
|
||||||
LLLL : 'dddd, YYYY [çулхи] MMMM [уйăхĕн] D[-мĕшĕ], LT'
|
LLLL : 'dddd, YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ], LT'
|
||||||
},
|
},
|
||||||
calendar : {
|
calendar : {
|
||||||
sameDay: '[Паян] LT [сехетре]',
|
sameDay: '[Паян] LT [сехетре]',
|
||||||
nextDay: '[Ыран] LT [сехетре]',
|
nextDay: '[Ыран] LT [сехетре]',
|
||||||
lastDay: '[Ĕнер] LT [сехетре]',
|
lastDay: '[Ӗнер] LT [сехетре]',
|
||||||
nextWeek: '[Çитес] dddd LT [сехетре]',
|
nextWeek: '[Ҫитес] dddd LT [сехетре]',
|
||||||
lastWeek: '[Иртнĕ] dddd LT [сехетре]',
|
lastWeek: '[Иртнӗ] dddd LT [сехетре]',
|
||||||
sameElse: 'L'
|
sameElse: 'L'
|
||||||
},
|
},
|
||||||
relativeTime : {
|
relativeTime : {
|
||||||
future : function (output) {
|
future : function (output) {
|
||||||
var affix = /сехет$/i.exec(output) ? 'рен' : /çул$/i.exec(output) ? 'тан' : 'ран';
|
var affix = /сехет$/i.exec(output) ? 'рен' : /ҫул$/i.exec(output) ? 'тан' : 'ран';
|
||||||
return output + affix;
|
return output + affix;
|
||||||
},
|
},
|
||||||
past : '%s каялла',
|
past : '%s каялла',
|
||||||
s : 'пĕр-ик çеккунт',
|
s : 'пӗр-ик ҫеккунт',
|
||||||
m : 'пĕр минут',
|
m : 'пӗр минут',
|
||||||
mm : '%d минут',
|
mm : '%d минут',
|
||||||
h : 'пĕр сехет',
|
h : 'пӗр сехет',
|
||||||
hh : '%d сехет',
|
hh : '%d сехет',
|
||||||
d : 'пĕр кун',
|
d : 'пӗр кун',
|
||||||
dd : '%d кун',
|
dd : '%d кун',
|
||||||
M : 'пĕр уйăх',
|
M : 'пӗр уйӑх',
|
||||||
MM : '%d уйăх',
|
MM : '%d уйӑх',
|
||||||
y : 'пĕр çул',
|
y : 'пӗр ҫул',
|
||||||
yy : '%d çул'
|
yy : '%d ҫул'
|
||||||
},
|
},
|
||||||
ordinalParse: /\d{1,2}-мĕш/,
|
ordinalParse: /\d{1,2}-мӗш/,
|
||||||
ordinal : '%d-мĕш',
|
ordinal : '%d-мӗш',
|
||||||
week : {
|
week : {
|
||||||
dow : 1, // Monday is the first day of the 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.
|
doy : 7 // The week that contains Jan 1st is the first week of the year.
|
||||||
|
@ -1936,11 +1936,11 @@
|
||||||
//! locale : spanish (es)
|
//! locale : spanish (es)
|
||||||
//! author : Julio Napurí : https://github.com/julionc
|
//! author : Julio Napurí : https://github.com/julionc
|
||||||
|
|
||||||
var monthsShortDot = '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('_');
|
es__monthsShort = 'Ene_Feb_Mar_Abr_May_Jun_Jul_Ago_Sep_Oct_Nov_Dic'.split('_');
|
||||||
|
|
||||||
var es = moment.defineLocale('es', {
|
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) {
|
monthsShort : function (m, format) {
|
||||||
if (/-MMM-/.test(format)) {
|
if (/-MMM-/.test(format)) {
|
||||||
return es__monthsShort[m.month()];
|
return es__monthsShort[m.month()];
|
||||||
|
@ -1948,8 +1948,8 @@
|
||||||
return monthsShortDot[m.month()];
|
return monthsShortDot[m.month()];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
weekdays : 'domingo_lunes_martes_miércoles_jueves_viernes_sábado'.split('_'),
|
weekdays : 'Domingo_Lunes_Martes_Miércoles_Jueves_Viernes_Sábado'.split('_'),
|
||||||
weekdaysShort : 'dom._lun._mar._mié._jue._vie._sáb.'.split('_'),
|
weekdaysShort : 'Dom._Lun._Mar._Mié._Jue._Vie._Sáb.'.split('_'),
|
||||||
weekdaysMin : 'Do_Lu_Ma_Mi_Ju_Vi_Sá'.split('_'),
|
weekdaysMin : 'Do_Lu_Ma_Mi_Ju_Vi_Sá'.split('_'),
|
||||||
longDateFormat : {
|
longDateFormat : {
|
||||||
LT : 'H:mm',
|
LT : 'H:mm',
|
||||||
|
@ -2824,8 +2824,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
var hr = moment.defineLocale('hr', {
|
var hr = moment.defineLocale('hr', {
|
||||||
months : 'sječanj_veljača_ožujak_travanj_svibanj_lipanj_srpanj_kolovoz_rujan_listopad_studeni_prosinac'.split('_'),
|
months : 'siječ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('_'),
|
monthsShort : 'sij._velj._ožu._tra._svi._lip._srp._kol._ruj._lis._stu._pro.'.split('_'),
|
||||||
weekdays : 'nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota'.split('_'),
|
weekdays : 'nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota'.split('_'),
|
||||||
weekdaysShort : 'ned._pon._uto._sri._čet._pet._sub.'.split('_'),
|
weekdaysShort : 'ned._pon._uto._sri._čet._pet._sub.'.split('_'),
|
||||||
weekdaysMin : 'ne_po_ut_sr_če_pe_su'.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
|
//! moment.js locale configuration
|
||||||
//! locale : Georgian (ka)
|
//! locale : Georgian (ka)
|
||||||
//! author : Irakli Janiashvili : https://github.com/irakli-janiashvili
|
//! author : Irakli Janiashvili : https://github.com/irakli-janiashvili
|
||||||
|
@ -3820,25 +3892,42 @@
|
||||||
//! moment.js locale configuration
|
//! moment.js locale configuration
|
||||||
//! locale : latvian (lv)
|
//! locale : latvian (lv)
|
||||||
//! author : Kristaps Karlsons : https://github.com/skakri
|
//! author : Kristaps Karlsons : https://github.com/skakri
|
||||||
|
//! author : Jānis Elmeris : https://github.com/JanisE
|
||||||
|
|
||||||
var lv__units = {
|
var lv__units = {
|
||||||
'mm': 'minūti_minūtes_minūte_minūtes',
|
'm': 'minūtes_minūtēm_minūte_minūtes'.split('_'),
|
||||||
'hh': 'stundu_stundas_stunda_stundas',
|
'mm': 'minūtes_minūtēm_minūte_minūtes'.split('_'),
|
||||||
'dd': 'dienu_dienas_diena_dienas',
|
'h': 'stundas_stundām_stunda_stundas'.split('_'),
|
||||||
'MM': 'mēnesi_mēnešus_mēnesis_mēneši',
|
'hh': 'stundas_stundām_stunda_stundas'.split('_'),
|
||||||
'yy': 'gadu_gadus_gads_gadi'
|
'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) {
|
if (withoutSuffix) {
|
||||||
|
// E.g. "21 minūte", "3 minūtes".
|
||||||
return number % 10 === 1 && number !== 11 ? forms[2] : forms[3];
|
return number % 10 === 1 && number !== 11 ? forms[2] : forms[3];
|
||||||
} else {
|
} 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];
|
return number % 10 === 1 && number !== 11 ? forms[0] : forms[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function lv__relativeTimeWithPlural(number, withoutSuffix, key) {
|
function lv__relativeTimeWithPlural(number, withoutSuffix, key) {
|
||||||
return number + ' ' + format(lv__units[key], number, withoutSuffix);
|
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', {
|
var lv = moment.defineLocale('lv', {
|
||||||
months : 'janvāris_februāris_marts_aprīlis_maijs_jūnijs_jūlijs_augusts_septembris_oktobris_novembris_decembris'.split('_'),
|
months : 'janvāris_februāris_marts_aprīlis_maijs_jūnijs_jūlijs_augusts_septembris_oktobris_novembris_decembris'.split('_'),
|
||||||
|
@ -3849,7 +3938,7 @@
|
||||||
longDateFormat : {
|
longDateFormat : {
|
||||||
LT : 'HH:mm',
|
LT : 'HH:mm',
|
||||||
LTS : 'LT:ss',
|
LTS : 'LT:ss',
|
||||||
L : 'DD.MM.YYYY',
|
L : 'DD.MM.YYYY.',
|
||||||
LL : 'YYYY. [gada] D. MMMM',
|
LL : 'YYYY. [gada] D. MMMM',
|
||||||
LLL : 'YYYY. [gada] D. MMMM, LT',
|
LLL : 'YYYY. [gada] D. MMMM, LT',
|
||||||
LLLL : 'YYYY. [gada] D. MMMM, dddd, LT'
|
LLLL : 'YYYY. [gada] D. MMMM, dddd, LT'
|
||||||
|
@ -3863,18 +3952,18 @@
|
||||||
sameElse : 'L'
|
sameElse : 'L'
|
||||||
},
|
},
|
||||||
relativeTime : {
|
relativeTime : {
|
||||||
future : '%s vēlāk',
|
future : 'pēc %s',
|
||||||
past : '%s agrāk',
|
past : 'pirms %s',
|
||||||
s : 'dažas sekundes',
|
s : relativeSeconds,
|
||||||
m : 'minūti',
|
m : relativeTimeWithSingular,
|
||||||
mm : lv__relativeTimeWithPlural,
|
mm : lv__relativeTimeWithPlural,
|
||||||
h : 'stundu',
|
h : relativeTimeWithSingular,
|
||||||
hh : lv__relativeTimeWithPlural,
|
hh : lv__relativeTimeWithPlural,
|
||||||
d : 'dienu',
|
d : relativeTimeWithSingular,
|
||||||
dd : lv__relativeTimeWithPlural,
|
dd : lv__relativeTimeWithPlural,
|
||||||
M : 'mēnesi',
|
M : relativeTimeWithSingular,
|
||||||
MM : lv__relativeTimeWithPlural,
|
MM : lv__relativeTimeWithPlural,
|
||||||
y : 'gadu',
|
y : relativeTimeWithSingular,
|
||||||
yy : lv__relativeTimeWithPlural
|
yy : lv__relativeTimeWithPlural
|
||||||
},
|
},
|
||||||
ordinalParse: /\d{1,2}\./,
|
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
|
//! moment.js locale configuration
|
||||||
//! locale : macedonian (mk)
|
//! locale : macedonian (mk)
|
||||||
//! author : Borislav Mickov : https://github.com/B0k0
|
//! author : Borislav Mickov : https://github.com/B0k0
|
||||||
|
@ -4237,8 +4424,9 @@
|
||||||
months: 'ဇန်နဝါရီ_ဖေဖော်ဝါရီ_မတ်_ဧပြီ_မေ_ဇွန်_ဇူလိုင်_သြဂုတ်_စက်တင်ဘာ_အောက်တိုဘာ_နိုဝင်ဘာ_ဒီဇင်ဘာ'.split('_'),
|
months: 'ဇန်နဝါရီ_ဖေဖော်ဝါရီ_မတ်_ဧပြီ_မေ_ဇွန်_ဇူလိုင်_သြဂုတ်_စက်တင်ဘာ_အောက်တိုဘာ_နိုဝင်ဘာ_ဒီဇင်ဘာ'.split('_'),
|
||||||
monthsShort: 'ဇန်_ဖေ_မတ်_ပြီ_မေ_ဇွန်_လိုင်_သြ_စက်_အောက်_နို_ဒီ'.split('_'),
|
monthsShort: 'ဇန်_ဖေ_မတ်_ပြီ_မေ_ဇွန်_လိုင်_သြ_စက်_အောက်_နို_ဒီ'.split('_'),
|
||||||
weekdays: 'တနင်္ဂနွေ_တနင်္လာ_အင်္ဂါ_ဗုဒ္ဓဟူး_ကြာသပတေး_သောကြာ_စနေ'.split('_'),
|
weekdays: 'တနင်္ဂနွေ_တနင်္လာ_အင်္ဂါ_ဗုဒ္ဓဟူး_ကြာသပတေး_သောကြာ_စနေ'.split('_'),
|
||||||
weekdaysShort: 'နွေ_လာ_င်္ဂါ_ဟူး_ကြာ_သော_နေ'.split('_'),
|
weekdaysShort: 'နွေ_လာ_ဂါ_ဟူး_ကြာ_သော_နေ'.split('_'),
|
||||||
weekdaysMin: 'နွေ_လာ_င်္ဂါ_ဟူး_ကြာ_သော_နေ'.split('_'),
|
weekdaysMin: 'နွေ_လာ_ဂါ_ဟူး_ကြာ_သော_နေ'.split('_'),
|
||||||
|
|
||||||
longDateFormat: {
|
longDateFormat: {
|
||||||
LT: 'HH:mm',
|
LT: 'HH:mm',
|
||||||
LTS: 'HH:mm:ss',
|
LTS: 'HH:mm:ss',
|
||||||
|
@ -4586,7 +4774,12 @@
|
||||||
|
|
||||||
var pl = moment.defineLocale('pl', {
|
var pl = moment.defineLocale('pl', {
|
||||||
months : function (momentToFormat, format) {
|
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()];
|
return monthsSubjective[momentToFormat.month()];
|
||||||
} else {
|
} else {
|
||||||
return monthsNominative[momentToFormat.month()];
|
return monthsNominative[momentToFormat.month()];
|
||||||
|
@ -4651,11 +4844,11 @@
|
||||||
//! author : Caio Ribeiro Pereira : https://github.com/caio-ribeiro-pereira
|
//! author : Caio Ribeiro Pereira : https://github.com/caio-ribeiro-pereira
|
||||||
|
|
||||||
var pt_br = moment.defineLocale('pt-br', {
|
var pt_br = moment.defineLocale('pt-br', {
|
||||||
months : 'janeiro_fevereiro_março_abril_maio_junho_julho_agosto_setembro_outubro_novembro_dezembro'.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('_'),
|
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('_'),
|
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('_'),
|
weekdaysShort : 'Dom_Seg_Ter_Qua_Qui_Sex_Sáb'.split('_'),
|
||||||
weekdaysMin : 'dom_2ª_3ª_4ª_5ª_6ª_sáb'.split('_'),
|
weekdaysMin : 'Dom_2ª_3ª_4ª_5ª_6ª_Sáb'.split('_'),
|
||||||
longDateFormat : {
|
longDateFormat : {
|
||||||
LT : 'HH:mm',
|
LT : 'HH:mm',
|
||||||
LTS : 'LT:ss',
|
LTS : 'LT:ss',
|
||||||
|
@ -4700,11 +4893,11 @@
|
||||||
//! author : Jefferson : https://github.com/jalex79
|
//! author : Jefferson : https://github.com/jalex79
|
||||||
|
|
||||||
var pt = moment.defineLocale('pt', {
|
var pt = moment.defineLocale('pt', {
|
||||||
months : 'janeiro_fevereiro_março_abril_maio_junho_julho_agosto_setembro_outubro_novembro_dezembro'.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('_'),
|
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('_'),
|
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('_'),
|
weekdaysShort : 'Dom_Seg_Ter_Qua_Qui_Sex_Sáb'.split('_'),
|
||||||
weekdaysMin : 'dom_2ª_3ª_4ª_5ª_6ª_sáb'.split('_'),
|
weekdaysMin : 'Dom_2ª_3ª_4ª_5ª_6ª_Sáb'.split('_'),
|
||||||
longDateFormat : {
|
longDateFormat : {
|
||||||
LT : 'HH:mm',
|
LT : 'HH:mm',
|
||||||
LTS : 'LT:ss',
|
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
|
//! moment.js locale configuration
|
||||||
//! locale : slovak (sk)
|
//! locale : slovak (sk)
|
||||||
//! author : Martin Minka : https://github.com/k2s
|
//! author : Martin Minka : https://github.com/k2s
|
||||||
|
@ -5115,62 +5362,72 @@
|
||||||
//! locale : slovenian (sl)
|
//! locale : slovenian (sl)
|
||||||
//! author : Robert Sedovšek : https://github.com/sedovsek
|
//! author : Robert Sedovšek : https://github.com/sedovsek
|
||||||
|
|
||||||
function sl__translate(number, withoutSuffix, key) {
|
function sl__processRelativeTime(number, withoutSuffix, key, isFuture) {
|
||||||
var result = number + ' ';
|
var result = number + ' ';
|
||||||
switch (key) {
|
switch (key) {
|
||||||
|
case 's':
|
||||||
|
return withoutSuffix || isFuture ? 'nekaj sekund' : 'nekaj sekundami';
|
||||||
case 'm':
|
case 'm':
|
||||||
return withoutSuffix ? 'ena minuta' : 'eno minuto';
|
return withoutSuffix ? 'ena minuta' : 'eno minuto';
|
||||||
case 'mm':
|
case 'mm':
|
||||||
if (number === 1) {
|
if (number === 1) {
|
||||||
result += 'minuta';
|
result += withoutSuffix ? 'minuta' : 'minuto';
|
||||||
} else if (number === 2) {
|
} else if (number === 2) {
|
||||||
result += 'minuti';
|
result += withoutSuffix || isFuture ? 'minuti' : 'minutama';
|
||||||
} else if (number === 3 || number === 4) {
|
} else if (number < 5) {
|
||||||
result += 'minute';
|
result += withoutSuffix || isFuture ? 'minute' : 'minutami';
|
||||||
} else {
|
} else {
|
||||||
result += 'minut';
|
result += withoutSuffix || isFuture ? 'minut' : 'minutami';
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
case 'h':
|
case 'h':
|
||||||
return withoutSuffix ? 'ena ura' : 'eno uro';
|
return withoutSuffix ? 'ena ura' : 'eno uro';
|
||||||
case 'hh':
|
case 'hh':
|
||||||
if (number === 1) {
|
if (number === 1) {
|
||||||
result += 'ura';
|
result += withoutSuffix ? 'ura' : 'uro';
|
||||||
} else if (number === 2) {
|
} else if (number === 2) {
|
||||||
result += 'uri';
|
result += withoutSuffix || isFuture ? 'uri' : 'urama';
|
||||||
} else if (number === 3 || number === 4) {
|
} else if (number < 5) {
|
||||||
result += 'ure';
|
result += withoutSuffix || isFuture ? 'ure' : 'urami';
|
||||||
} else {
|
} else {
|
||||||
result += 'ur';
|
result += withoutSuffix || isFuture ? 'ur' : 'urami';
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
case 'd':
|
||||||
|
return withoutSuffix || isFuture ? 'en dan' : 'enim dnem';
|
||||||
case 'dd':
|
case 'dd':
|
||||||
if (number === 1) {
|
if (number === 1) {
|
||||||
result += 'dan';
|
result += withoutSuffix || isFuture ? 'dan' : 'dnem';
|
||||||
|
} else if (number === 2) {
|
||||||
|
result += withoutSuffix || isFuture ? 'dni' : 'dnevoma';
|
||||||
} else {
|
} else {
|
||||||
result += 'dni';
|
result += withoutSuffix || isFuture ? 'dni' : 'dnevi';
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
case 'M':
|
||||||
|
return withoutSuffix || isFuture ? 'en mesec' : 'enim mesecem';
|
||||||
case 'MM':
|
case 'MM':
|
||||||
if (number === 1) {
|
if (number === 1) {
|
||||||
result += 'mesec';
|
result += withoutSuffix || isFuture ? 'mesec' : 'mesecem';
|
||||||
} else if (number === 2) {
|
} else if (number === 2) {
|
||||||
result += 'meseca';
|
result += withoutSuffix || isFuture ? 'meseca' : 'mesecema';
|
||||||
} else if (number === 3 || number === 4) {
|
} else if (number < 5) {
|
||||||
result += 'mesece';
|
result += withoutSuffix || isFuture ? 'mesece' : 'meseci';
|
||||||
} else {
|
} else {
|
||||||
result += 'mesecev';
|
result += withoutSuffix || isFuture ? 'mesecev' : 'meseci';
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
case 'y':
|
||||||
|
return withoutSuffix || isFuture ? 'eno leto' : 'enim letom';
|
||||||
case 'yy':
|
case 'yy':
|
||||||
if (number === 1) {
|
if (number === 1) {
|
||||||
result += 'leto';
|
result += withoutSuffix || isFuture ? 'leto' : 'letom';
|
||||||
} else if (number === 2) {
|
} else if (number === 2) {
|
||||||
result += 'leti';
|
result += withoutSuffix || isFuture ? 'leti' : 'letoma';
|
||||||
} else if (number === 3 || number === 4) {
|
} else if (number < 5) {
|
||||||
result += 'leta';
|
result += withoutSuffix || isFuture ? 'leta' : 'leti';
|
||||||
} else {
|
} else {
|
||||||
result += 'let';
|
result += withoutSuffix || isFuture ? 'let' : 'leti';
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -5193,6 +5450,7 @@
|
||||||
calendar : {
|
calendar : {
|
||||||
sameDay : '[danes ob] LT',
|
sameDay : '[danes ob] LT',
|
||||||
nextDay : '[jutri ob] LT',
|
nextDay : '[jutri ob] LT',
|
||||||
|
|
||||||
nextWeek : function () {
|
nextWeek : function () {
|
||||||
switch (this.day()) {
|
switch (this.day()) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -5212,9 +5470,11 @@
|
||||||
lastWeek : function () {
|
lastWeek : function () {
|
||||||
switch (this.day()) {
|
switch (this.day()) {
|
||||||
case 0:
|
case 0:
|
||||||
|
return '[prejšnjo] [nedeljo] [ob] LT';
|
||||||
case 3:
|
case 3:
|
||||||
|
return '[prejšnjo] [sredo] [ob] LT';
|
||||||
case 6:
|
case 6:
|
||||||
return '[prejšnja] dddd [ob] LT';
|
return '[prejšnjo] [soboto] [ob] LT';
|
||||||
case 1:
|
case 1:
|
||||||
case 2:
|
case 2:
|
||||||
case 4:
|
case 4:
|
||||||
|
@ -5226,18 +5486,18 @@
|
||||||
},
|
},
|
||||||
relativeTime : {
|
relativeTime : {
|
||||||
future : 'čez %s',
|
future : 'čez %s',
|
||||||
past : '%s nazaj',
|
past : 'pred %s',
|
||||||
s : 'nekaj sekund',
|
s : sl__processRelativeTime,
|
||||||
m : sl__translate,
|
m : sl__processRelativeTime,
|
||||||
mm : sl__translate,
|
mm : sl__processRelativeTime,
|
||||||
h : sl__translate,
|
h : sl__processRelativeTime,
|
||||||
hh : sl__translate,
|
hh : sl__processRelativeTime,
|
||||||
d : 'en dan',
|
d : sl__processRelativeTime,
|
||||||
dd : sl__translate,
|
dd : sl__processRelativeTime,
|
||||||
M : 'en mesec',
|
M : sl__processRelativeTime,
|
||||||
MM : sl__translate,
|
MM : sl__processRelativeTime,
|
||||||
y : 'eno leto',
|
y : sl__processRelativeTime,
|
||||||
yy : sl__translate
|
yy : sl__processRelativeTime
|
||||||
},
|
},
|
||||||
ordinalParse: /\d{1,2}\./,
|
ordinalParse: /\d{1,2}\./,
|
||||||
ordinal : '%d.',
|
ordinal : '%d.',
|
||||||
|
@ -5521,8 +5781,8 @@
|
||||||
sameDay: '[Idag] LT',
|
sameDay: '[Idag] LT',
|
||||||
nextDay: '[Imorgon] LT',
|
nextDay: '[Imorgon] LT',
|
||||||
lastDay: '[Igår] LT',
|
lastDay: '[Igår] LT',
|
||||||
nextWeek: 'dddd LT',
|
nextWeek: '[På] dddd LT',
|
||||||
lastWeek: '[Förra] dddd[en] LT',
|
lastWeek: '[I] dddd[s] LT',
|
||||||
sameElse: 'L'
|
sameElse: 'L'
|
||||||
},
|
},
|
||||||
relativeTime : {
|
relativeTime : {
|
||||||
|
@ -6173,7 +6433,7 @@
|
||||||
weekdaysShort : '周日_周一_周二_周三_周四_周五_周六'.split('_'),
|
weekdaysShort : '周日_周一_周二_周三_周四_周五_周六'.split('_'),
|
||||||
weekdaysMin : '日_一_二_三_四_五_六'.split('_'),
|
weekdaysMin : '日_一_二_三_四_五_六'.split('_'),
|
||||||
longDateFormat : {
|
longDateFormat : {
|
||||||
LT : 'Ah点mm',
|
LT : 'Ah点mm分',
|
||||||
LTS : 'Ah点m分s秒',
|
LTS : 'Ah点m分s秒',
|
||||||
L : 'YYYY-MM-DD',
|
L : 'YYYY-MM-DD',
|
||||||
LL : 'YYYY年MMMD日',
|
LL : 'YYYY年MMMD日',
|
||||||
|
@ -6259,16 +6519,16 @@
|
||||||
future : '%s内',
|
future : '%s内',
|
||||||
past : '%s前',
|
past : '%s前',
|
||||||
s : '几秒',
|
s : '几秒',
|
||||||
m : '1分钟',
|
m : '1 分钟',
|
||||||
mm : '%d分钟',
|
mm : '%d 分钟',
|
||||||
h : '1小时',
|
h : '1 小时',
|
||||||
hh : '%d小时',
|
hh : '%d 小时',
|
||||||
d : '1天',
|
d : '1 天',
|
||||||
dd : '%d天',
|
dd : '%d 天',
|
||||||
M : '1个月',
|
M : '1 个月',
|
||||||
MM : '%d个月',
|
MM : '%d 个月',
|
||||||
y : '1年',
|
y : '1 年',
|
||||||
yy : '%d年'
|
yy : '%d 年'
|
||||||
},
|
},
|
||||||
week : {
|
week : {
|
||||||
// GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
|
// GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
|
||||||
|
@ -6288,7 +6548,7 @@
|
||||||
weekdaysShort : '週日_週一_週二_週三_週四_週五_週六'.split('_'),
|
weekdaysShort : '週日_週一_週二_週三_週四_週五_週六'.split('_'),
|
||||||
weekdaysMin : '日_一_二_三_四_五_六'.split('_'),
|
weekdaysMin : '日_一_二_三_四_五_六'.split('_'),
|
||||||
longDateFormat : {
|
longDateFormat : {
|
||||||
LT : 'Ah點mm',
|
LT : 'Ah點mm分',
|
||||||
LTS : 'Ah點m分s秒',
|
LTS : 'Ah點m分s秒',
|
||||||
L : 'YYYY年MMMD日',
|
L : 'YYYY年MMMD日',
|
||||||
LL : '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
|
//! moment.js
|
||||||
//! version : 2.10.2
|
//! version : 2.10.3
|
||||||
//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
|
//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
|
||||||
//! license : MIT
|
//! license : MIT
|
||||||
//! momentjs.com
|
//! momentjs.com
|
||||||
|
@ -22,28 +22,12 @@
|
||||||
hookCallback = callback;
|
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) {
|
function isArray(input) {
|
||||||
return Object.prototype.toString.call(input) === '[object Array]';
|
return Object.prototype.toString.call(input) === '[object Array]';
|
||||||
}
|
}
|
||||||
|
|
||||||
function isDate(input) {
|
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) {
|
function map(arr, fn) {
|
||||||
|
@ -80,21 +64,45 @@
|
||||||
return createLocalOrUTC(input, format, locale, strict, true).utc();
|
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) {
|
function valid__isValid(m) {
|
||||||
if (m._isValid == null) {
|
if (m._isValid == null) {
|
||||||
|
var flags = getParsingFlags(m);
|
||||||
m._isValid = !isNaN(m._d.getTime()) &&
|
m._isValid = !isNaN(m._d.getTime()) &&
|
||||||
m._pf.overflow < 0 &&
|
flags.overflow < 0 &&
|
||||||
!m._pf.empty &&
|
!flags.empty &&
|
||||||
!m._pf.invalidMonth &&
|
!flags.invalidMonth &&
|
||||||
!m._pf.nullInput &&
|
!flags.nullInput &&
|
||||||
!m._pf.invalidFormat &&
|
!flags.invalidFormat &&
|
||||||
!m._pf.userInvalidated;
|
!flags.userInvalidated;
|
||||||
|
|
||||||
if (m._strict) {
|
if (m._strict) {
|
||||||
m._isValid = m._isValid &&
|
m._isValid = m._isValid &&
|
||||||
m._pf.charsLeftOver === 0 &&
|
flags.charsLeftOver === 0 &&
|
||||||
m._pf.unusedTokens.length === 0 &&
|
flags.unusedTokens.length === 0 &&
|
||||||
m._pf.bigHour === undefined;
|
flags.bigHour === undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return m._isValid;
|
return m._isValid;
|
||||||
|
@ -103,10 +111,10 @@
|
||||||
function valid__createInvalid (flags) {
|
function valid__createInvalid (flags) {
|
||||||
var m = create_utc__createUTC(NaN);
|
var m = create_utc__createUTC(NaN);
|
||||||
if (flags != null) {
|
if (flags != null) {
|
||||||
extend(m._pf, flags);
|
extend(getParsingFlags(m), flags);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m._pf.userInvalidated = true;
|
getParsingFlags(m).userInvalidated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return m;
|
return m;
|
||||||
|
@ -142,7 +150,7 @@
|
||||||
to._offset = from._offset;
|
to._offset = from._offset;
|
||||||
}
|
}
|
||||||
if (typeof from._pf !== 'undefined') {
|
if (typeof from._pf !== 'undefined') {
|
||||||
to._pf = from._pf;
|
to._pf = getParsingFlags(from);
|
||||||
}
|
}
|
||||||
if (typeof from._locale !== 'undefined') {
|
if (typeof from._locale !== 'undefined') {
|
||||||
to._locale = from._locale;
|
to._locale = from._locale;
|
||||||
|
@ -177,7 +185,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function isMoment (obj) {
|
function isMoment (obj) {
|
||||||
return obj instanceof Moment || (obj != null && hasOwnProp(obj, '_isAMomentObject'));
|
return obj instanceof Moment || (obj != null && obj._isAMomentObject != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
function toInt(argumentForCoercion) {
|
function toInt(argumentForCoercion) {
|
||||||
|
@ -615,7 +623,7 @@
|
||||||
if (month != null) {
|
if (month != null) {
|
||||||
array[MONTH] = month;
|
array[MONTH] = month;
|
||||||
} else {
|
} else {
|
||||||
config._pf.invalidMonth = input;
|
getParsingFlags(config).invalidMonth = input;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -699,7 +707,7 @@
|
||||||
var overflow;
|
var overflow;
|
||||||
var a = m._a;
|
var a = m._a;
|
||||||
|
|
||||||
if (a && m._pf.overflow === -2) {
|
if (a && getParsingFlags(m).overflow === -2) {
|
||||||
overflow =
|
overflow =
|
||||||
a[MONTH] < 0 || a[MONTH] > 11 ? MONTH :
|
a[MONTH] < 0 || a[MONTH] > 11 ? MONTH :
|
||||||
a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH]) ? DATE :
|
a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH]) ? DATE :
|
||||||
|
@ -709,11 +717,11 @@
|
||||||
a[MILLISECOND] < 0 || a[MILLISECOND] > 999 ? MILLISECOND :
|
a[MILLISECOND] < 0 || a[MILLISECOND] > 999 ? MILLISECOND :
|
||||||
-1;
|
-1;
|
||||||
|
|
||||||
if (m._pf._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) {
|
if (getParsingFlags(m)._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) {
|
||||||
overflow = DATE;
|
overflow = DATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
m._pf.overflow = overflow;
|
getParsingFlags(m).overflow = overflow;
|
||||||
}
|
}
|
||||||
|
|
||||||
return m;
|
return m;
|
||||||
|
@ -726,10 +734,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function deprecate(msg, fn) {
|
function deprecate(msg, fn) {
|
||||||
var firstTime = true;
|
var firstTime = true,
|
||||||
|
msgWithStack = msg + '\n' + (new Error()).stack;
|
||||||
|
|
||||||
return extend(function () {
|
return extend(function () {
|
||||||
if (firstTime) {
|
if (firstTime) {
|
||||||
warn(msg);
|
warn(msgWithStack);
|
||||||
firstTime = false;
|
firstTime = false;
|
||||||
}
|
}
|
||||||
return fn.apply(this, arguments);
|
return fn.apply(this, arguments);
|
||||||
|
@ -774,7 +784,7 @@
|
||||||
match = from_string__isoRegex.exec(string);
|
match = from_string__isoRegex.exec(string);
|
||||||
|
|
||||||
if (match) {
|
if (match) {
|
||||||
config._pf.iso = true;
|
getParsingFlags(config).iso = true;
|
||||||
for (i = 0, l = isoDates.length; i < l; i++) {
|
for (i = 0, l = isoDates.length; i < l; i++) {
|
||||||
if (isoDates[i][1].exec(string)) {
|
if (isoDates[i][1].exec(string)) {
|
||||||
// match[5] should be 'T' or undefined
|
// match[5] should be 'T' or undefined
|
||||||
|
@ -1054,7 +1064,7 @@
|
||||||
yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
|
yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
|
||||||
|
|
||||||
if (config._dayOfYear > daysInYear(yearToUse)) {
|
if (config._dayOfYear > daysInYear(yearToUse)) {
|
||||||
config._pf._overflowDayOfYear = true;
|
getParsingFlags(config)._overflowDayOfYear = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
date = createUTCDate(yearToUse, 0, config._dayOfYear);
|
date = createUTCDate(yearToUse, 0, config._dayOfYear);
|
||||||
|
@ -1150,7 +1160,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
config._a = [];
|
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`
|
// This array is used to make a Date, either with `new Date` or `Date.UTC`
|
||||||
var string = '' + config._i,
|
var string = '' + config._i,
|
||||||
|
@ -1166,7 +1176,7 @@
|
||||||
if (parsedInput) {
|
if (parsedInput) {
|
||||||
skipped = string.substr(0, string.indexOf(parsedInput));
|
skipped = string.substr(0, string.indexOf(parsedInput));
|
||||||
if (skipped.length > 0) {
|
if (skipped.length > 0) {
|
||||||
config._pf.unusedInput.push(skipped);
|
getParsingFlags(config).unusedInput.push(skipped);
|
||||||
}
|
}
|
||||||
string = string.slice(string.indexOf(parsedInput) + parsedInput.length);
|
string = string.slice(string.indexOf(parsedInput) + parsedInput.length);
|
||||||
totalParsedInputLength += parsedInput.length;
|
totalParsedInputLength += parsedInput.length;
|
||||||
|
@ -1174,27 +1184,29 @@
|
||||||
// don't parse if it's not a known token
|
// don't parse if it's not a known token
|
||||||
if (formatTokenFunctions[token]) {
|
if (formatTokenFunctions[token]) {
|
||||||
if (parsedInput) {
|
if (parsedInput) {
|
||||||
config._pf.empty = false;
|
getParsingFlags(config).empty = false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
config._pf.unusedTokens.push(token);
|
getParsingFlags(config).unusedTokens.push(token);
|
||||||
}
|
}
|
||||||
addTimeToArrayFromToken(token, parsedInput, config);
|
addTimeToArrayFromToken(token, parsedInput, config);
|
||||||
}
|
}
|
||||||
else if (config._strict && !parsedInput) {
|
else if (config._strict && !parsedInput) {
|
||||||
config._pf.unusedTokens.push(token);
|
getParsingFlags(config).unusedTokens.push(token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// add remaining unparsed input length to the string
|
// add remaining unparsed input length to the string
|
||||||
config._pf.charsLeftOver = stringLength - totalParsedInputLength;
|
getParsingFlags(config).charsLeftOver = stringLength - totalParsedInputLength;
|
||||||
if (string.length > 0) {
|
if (string.length > 0) {
|
||||||
config._pf.unusedInput.push(string);
|
getParsingFlags(config).unusedInput.push(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear _12h flag if hour is <= 12
|
// clear _12h flag if hour is <= 12
|
||||||
if (config._pf.bigHour === true && config._a[HOUR] <= 12) {
|
if (getParsingFlags(config).bigHour === true &&
|
||||||
config._pf.bigHour = undefined;
|
config._a[HOUR] <= 12 &&
|
||||||
|
config._a[HOUR] > 0) {
|
||||||
|
getParsingFlags(config).bigHour = undefined;
|
||||||
}
|
}
|
||||||
// handle meridiem
|
// handle meridiem
|
||||||
config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem);
|
config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem);
|
||||||
|
@ -1238,7 +1250,7 @@
|
||||||
currentScore;
|
currentScore;
|
||||||
|
|
||||||
if (config._f.length === 0) {
|
if (config._f.length === 0) {
|
||||||
config._pf.invalidFormat = true;
|
getParsingFlags(config).invalidFormat = true;
|
||||||
config._d = new Date(NaN);
|
config._d = new Date(NaN);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1249,7 +1261,6 @@
|
||||||
if (config._useUTC != null) {
|
if (config._useUTC != null) {
|
||||||
tempConfig._useUTC = config._useUTC;
|
tempConfig._useUTC = config._useUTC;
|
||||||
}
|
}
|
||||||
tempConfig._pf = defaultParsingFlags();
|
|
||||||
tempConfig._f = config._f[i];
|
tempConfig._f = config._f[i];
|
||||||
configFromStringAndFormat(tempConfig);
|
configFromStringAndFormat(tempConfig);
|
||||||
|
|
||||||
|
@ -1258,12 +1269,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// if there is any input that was not parsed add a penalty for that format
|
// 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
|
//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) {
|
if (scoreToBeat == null || currentScore < scoreToBeat) {
|
||||||
scoreToBeat = currentScore;
|
scoreToBeat = currentScore;
|
||||||
|
@ -1306,6 +1317,8 @@
|
||||||
configFromStringAndArray(config);
|
configFromStringAndArray(config);
|
||||||
} else if (format) {
|
} else if (format) {
|
||||||
configFromStringAndFormat(config);
|
configFromStringAndFormat(config);
|
||||||
|
} else if (isDate(input)) {
|
||||||
|
config._d = input;
|
||||||
} else {
|
} else {
|
||||||
configFromInput(config);
|
configFromInput(config);
|
||||||
}
|
}
|
||||||
|
@ -1358,7 +1371,6 @@
|
||||||
c._i = input;
|
c._i = input;
|
||||||
c._f = format;
|
c._f = format;
|
||||||
c._strict = strict;
|
c._strict = strict;
|
||||||
c._pf = defaultParsingFlags();
|
|
||||||
|
|
||||||
return createFromConfig(c);
|
return createFromConfig(c);
|
||||||
}
|
}
|
||||||
|
@ -1932,6 +1944,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function from (time, withoutSuffix) {
|
function from (time, withoutSuffix) {
|
||||||
|
if (!this.isValid()) {
|
||||||
|
return this.localeData().invalidDate();
|
||||||
|
}
|
||||||
return create__createDuration({to: this, from: time}).locale(this.locale()).humanize(!withoutSuffix);
|
return create__createDuration({to: this, from: time}).locale(this.locale()).humanize(!withoutSuffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1939,6 +1954,17 @@
|
||||||
return this.from(local__createLocal(), withoutSuffix);
|
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) {
|
function locale (key) {
|
||||||
var newLocaleData;
|
var newLocaleData;
|
||||||
|
|
||||||
|
@ -2041,11 +2067,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function parsingFlags () {
|
function parsingFlags () {
|
||||||
return extend({}, this._pf);
|
return extend({}, getParsingFlags(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
function invalidAt () {
|
function invalidAt () {
|
||||||
return this._pf.overflow;
|
return getParsingFlags(this).overflow;
|
||||||
}
|
}
|
||||||
|
|
||||||
addFormatToken(0, ['gg', 2], 0, function () {
|
addFormatToken(0, ['gg', 2], 0, function () {
|
||||||
|
@ -2196,7 +2222,7 @@
|
||||||
if (weekday != null) {
|
if (weekday != null) {
|
||||||
week.d = weekday;
|
week.d = weekday;
|
||||||
} else {
|
} else {
|
||||||
config._pf.invalidWeekday = input;
|
getParsingFlags(config).invalidWeekday = input;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -2321,7 +2347,7 @@
|
||||||
});
|
});
|
||||||
addParseToken(['h', 'hh'], function (input, array, config) {
|
addParseToken(['h', 'hh'], function (input, array, config) {
|
||||||
array[HOUR] = toInt(input);
|
array[HOUR] = toInt(input);
|
||||||
config._pf.bigHour = true;
|
getParsingFlags(config).bigHour = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
// LOCALES
|
// LOCALES
|
||||||
|
@ -2438,6 +2464,8 @@
|
||||||
momentPrototype__proto.format = format;
|
momentPrototype__proto.format = format;
|
||||||
momentPrototype__proto.from = from;
|
momentPrototype__proto.from = from;
|
||||||
momentPrototype__proto.fromNow = fromNow;
|
momentPrototype__proto.fromNow = fromNow;
|
||||||
|
momentPrototype__proto.to = to;
|
||||||
|
momentPrototype__proto.toNow = toNow;
|
||||||
momentPrototype__proto.get = getSet;
|
momentPrototype__proto.get = getSet;
|
||||||
momentPrototype__proto.invalidAt = invalidAt;
|
momentPrototype__proto.invalidAt = invalidAt;
|
||||||
momentPrototype__proto.isAfter = isAfter;
|
momentPrototype__proto.isAfter = isAfter;
|
||||||
|
@ -2626,7 +2654,7 @@
|
||||||
}
|
}
|
||||||
// Lenient ordinal parsing accepts just a number in addition to
|
// Lenient ordinal parsing accepts just a number in addition to
|
||||||
// number + (possibly) stuff coming from _ordinalParseLenient.
|
// 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;
|
var prototype__proto = Locale.prototype;
|
||||||
|
@ -2843,13 +2871,13 @@
|
||||||
// handle milliseconds separately because of floating point math errors (issue #1867)
|
// handle milliseconds separately because of floating point math errors (issue #1867)
|
||||||
days = this._days + Math.round(yearsToDays(this._months / 12));
|
days = this._days + Math.round(yearsToDays(this._months / 12));
|
||||||
switch (units) {
|
switch (units) {
|
||||||
case 'week' : return days / 7 + milliseconds / 6048e5;
|
case 'week' : return days / 7 + milliseconds / 6048e5;
|
||||||
case 'day' : return days + milliseconds / 864e5;
|
case 'day' : return days + milliseconds / 864e5;
|
||||||
case 'hour' : return days * 24 + milliseconds / 36e5;
|
case 'hour' : return days * 24 + milliseconds / 36e5;
|
||||||
case 'minute' : return days * 24 * 60 + milliseconds / 6e4;
|
case 'minute' : return days * 1440 + milliseconds / 6e4;
|
||||||
case 'second' : return days * 24 * 60 * 60 + milliseconds / 1000;
|
case 'second' : return days * 86400 + milliseconds / 1000;
|
||||||
// Math.floor prevents floating point math errors here
|
// 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);
|
default: throw new Error('Unknown unit ' + units);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3050,7 +3078,7 @@
|
||||||
// Side effect imports
|
// Side effect imports
|
||||||
|
|
||||||
|
|
||||||
utils_hooks__hooks.version = '2.10.2';
|
utils_hooks__hooks.version = '2.10.3';
|
||||||
|
|
||||||
setHookCallback(local__createLocal);
|
setHookCallback(local__createLocal);
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "moment",
|
"name": "moment",
|
||||||
"version": "2.10.2",
|
"version": "2.10.3",
|
||||||
"description": "Parse, validate, manipulate, and display dates",
|
"description": "Parse, validate, manipulate, and display dates",
|
||||||
"homepage": "http://momentjs.com",
|
"homepage": "http://momentjs.com",
|
||||||
"author": {
|
"author": {
|
||||||
|
@ -113,10 +113,10 @@
|
||||||
"locale/*.js"
|
"locale/*.js"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"_id": "moment@2.10.2",
|
"_id": "moment@2.10.3",
|
||||||
"dist": {
|
"dist": {
|
||||||
"shasum": "faf8c09ca82f03f94962e3b5a7239263ea50d087",
|
"shasum": "0abb99f307f65218308c6935efe29c57b1a0a27f",
|
||||||
"tarball": "http://registry.npmjs.org/moment/-/moment-2.10.2.tgz"
|
"tarball": "http://registry.npmjs.org/moment/-/moment-2.10.3.tgz"
|
||||||
},
|
},
|
||||||
"_from": "moment@>=2.0.0 <3.0.0",
|
"_from": "moment@>=2.0.0 <3.0.0",
|
||||||
"_npmVersion": "1.4.6",
|
"_npmVersion": "1.4.6",
|
||||||
|
@ -135,7 +135,6 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"directories": {},
|
"directories": {},
|
||||||
"_shasum": "faf8c09ca82f03f94962e3b5a7239263ea50d087",
|
"_shasum": "0abb99f307f65218308c6935efe29c57b1a0a27f",
|
||||||
"_resolved": "https://registry.npmjs.org/moment/-/moment-2.10.2.tgz",
|
"_resolved": "https://registry.npmjs.org/moment/-/moment-2.10.3.tgz"
|
||||||
"readme": "ERROR: No README data found!"
|
|
||||||
}
|
}
|
||||||
|
|
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",
|
"version": "1.0.2",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git://github.com/hapijs/topo"
|
"url": "git://github.com/hapijs/topo.git"
|
||||||
},
|
},
|
||||||
"main": "index",
|
"main": "index",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
|
|
@ -1,18 +1,19 @@
|
||||||
{
|
{
|
||||||
"name": "joi",
|
"name": "joi",
|
||||||
"description": "Object schema validation",
|
"description": "Object schema validation",
|
||||||
"version": "6.1.0",
|
"version": "6.4.3",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git://github.com/hapijs/joi"
|
"url": "git://github.com/hapijs/joi.git"
|
||||||
},
|
},
|
||||||
"main": "index",
|
"main": "lib/index.js",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"schema",
|
"schema",
|
||||||
"validation"
|
"validation"
|
||||||
],
|
],
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.10.30"
|
"node": ">=0.10.30",
|
||||||
|
"npm": "2.x"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"hoek": "^2.2.x",
|
"hoek": "^2.2.x",
|
||||||
|
@ -30,25 +31,25 @@
|
||||||
"test-cov-html": "lab -r html -o coverage.html -a code",
|
"test-cov-html": "lab -r html -o coverage.html -a code",
|
||||||
"toc": "node generate-readme-toc.js"
|
"toc": "node generate-readme-toc.js"
|
||||||
},
|
},
|
||||||
"licenses": [
|
"license": "BSD-3-Clause",
|
||||||
{
|
"gitHead": "de65dc5ab5054976b9bb6a728563f39cb310780b",
|
||||||
"type": "BSD",
|
|
||||||
"url": "http://github.com/hapijs/joi/raw/master/LICENSE"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"gitHead": "a395450ab6adb85c68cf0dd38e8e000a4694e990",
|
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/hapijs/joi/issues"
|
"url": "https://github.com/hapijs/joi/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/hapijs/joi",
|
"homepage": "https://github.com/hapijs/joi#readme",
|
||||||
"_id": "joi@6.1.0",
|
"_id": "joi@6.4.3",
|
||||||
"_shasum": "4141230a69866d12059c0a3ebe85b09ff8246779",
|
"_shasum": "340176729c65cf11ef063306be7e726a8e38c665",
|
||||||
"_from": "joi@6.1.0",
|
"_from": "joi@6.4.3",
|
||||||
"_npmVersion": "1.4.28",
|
"_npmVersion": "2.8.4",
|
||||||
|
"_nodeVersion": "0.10.30",
|
||||||
"_npmUser": {
|
"_npmUser": {
|
||||||
"name": "marsup",
|
"name": "marsup",
|
||||||
"email": "marsup@gmail.com"
|
"email": "marsup@gmail.com"
|
||||||
},
|
},
|
||||||
|
"dist": {
|
||||||
|
"shasum": "340176729c65cf11ef063306be7e726a8e38c665",
|
||||||
|
"tarball": "http://registry.npmjs.org/joi/-/joi-6.4.3.tgz"
|
||||||
|
},
|
||||||
"maintainers": [
|
"maintainers": [
|
||||||
{
|
{
|
||||||
"name": "hueniverse",
|
"name": "hueniverse",
|
||||||
|
@ -59,10 +60,6 @@
|
||||||
"email": "marsup@gmail.com"
|
"email": "marsup@gmail.com"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"dist": {
|
|
||||||
"shasum": "4141230a69866d12059c0a3ebe85b09ff8246779",
|
|
||||||
"tarball": "http://registry.npmjs.org/joi/-/joi-6.1.0.tgz"
|
|
||||||
},
|
|
||||||
"directories": {},
|
"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);
|
], 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) {
|
it('validates when is has ref', function (done) {
|
||||||
|
|
||||||
var schema = {
|
var schema = {
|
||||||
|
@ -291,7 +307,8 @@ describe('alternatives', function () {
|
||||||
is: {
|
is: {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
flags: {
|
flags: {
|
||||||
allowOnly: true
|
allowOnly: true,
|
||||||
|
presence: 'required'
|
||||||
},
|
},
|
||||||
valids: [5],
|
valids: [5],
|
||||||
invalids: [Infinity, -Infinity]
|
invalids: [Infinity, -Infinity]
|
||||||
|
@ -352,7 +369,8 @@ describe('alternatives', function () {
|
||||||
is: {
|
is: {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
flags: {
|
flags: {
|
||||||
allowOnly: true
|
allowOnly: true,
|
||||||
|
presence: 'required'
|
||||||
},
|
},
|
||||||
valids: [5],
|
valids: [5],
|
||||||
invalids: [Infinity, -Infinity]
|
invalids: [Infinity, -Infinity]
|
||||||
|
@ -405,7 +423,8 @@ describe('alternatives', function () {
|
||||||
is: {
|
is: {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
flags: {
|
flags: {
|
||||||
allowOnly: true
|
allowOnly: true,
|
||||||
|
presence: 'required'
|
||||||
},
|
},
|
||||||
valids: [5],
|
valids: [5],
|
||||||
invalids: [Infinity, -Infinity]
|
invalids: [Infinity, -Infinity]
|
||||||
|
|
|
@ -245,7 +245,13 @@ describe('any', function () {
|
||||||
|
|
||||||
expect(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();
|
}).to.throw();
|
||||||
|
|
||||||
done();
|
done();
|
||||||
|
@ -269,7 +275,12 @@ describe('any', function () {
|
||||||
|
|
||||||
it('sets the value when passing a method', function (done) {
|
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 = {};
|
var input = {};
|
||||||
|
|
||||||
schema.validate(input, function (err, value) {
|
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) {
|
it('executes the default method each time validate is called', function (done) {
|
||||||
|
|
||||||
var count = 0;
|
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 = {};
|
var input = {};
|
||||||
|
|
||||||
schema.validate(input, function (err, value) {
|
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) {
|
it('passes a clone of the context if the default method accepts an argument', function (done) {
|
||||||
|
|
||||||
var schema = Joi.object({
|
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()
|
bar: Joi.string()
|
||||||
});
|
});
|
||||||
var input = { bar: 'test' };
|
var input = { bar: 'test' };
|
||||||
|
@ -506,6 +525,34 @@ describe('any', function () {
|
||||||
done();
|
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 () {
|
describe('#optional', function () {
|
||||||
|
@ -750,7 +797,7 @@ describe('any', function () {
|
||||||
expect(function () {
|
expect(function () {
|
||||||
|
|
||||||
Joi.string().concat(Joi.number());
|
Joi.string().concat(Joi.number());
|
||||||
}).to.throw('Cannot merge with another type: number');
|
}).to.throw('Cannot merge type string with another type: number');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1018,7 +1065,7 @@ describe('any', function () {
|
||||||
expect(function () {
|
expect(function () {
|
||||||
|
|
||||||
a.concat(b);
|
a.concat(b);
|
||||||
}).to.throw('Cannot merge with another type: string');
|
}).to.throw('Cannot merge type number with another type: string');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1054,6 +1101,23 @@ describe('any', function () {
|
||||||
|
|
||||||
done();
|
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 () {
|
describe('#when', function () {
|
||||||
|
@ -1124,6 +1188,25 @@ describe('any', function () {
|
||||||
], done);
|
], 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) {
|
it('makes peer required', function (done) {
|
||||||
|
|
||||||
var schema = {
|
var schema = {
|
||||||
|
@ -1184,18 +1267,23 @@ describe('any', function () {
|
||||||
|
|
||||||
it('should throw on unknown key', function (done) {
|
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');
|
Joi.object({ a: 0, b: 0 }).requiredKeys('a', 'c', 'b', 'd', 'd.e.f');
|
||||||
}).to.throw(Error, 'unknown key(s) c, d');
|
}).to.throw(Error, 'unknown key(s) c, d');
|
||||||
expect(function() {
|
|
||||||
|
expect(function () {
|
||||||
|
|
||||||
Joi.object({ a: 0, b: 0 }).requiredKeys('a', 'b', 'a.c.d');
|
Joi.object({ a: 0, b: 0 }).requiredKeys('a', 'b', 'a.c.d');
|
||||||
}).to.throw(Error, 'unknown key(s) a.c.d');
|
}).to.throw(Error, 'unknown key(s) a.c.d');
|
||||||
|
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw on empty object', function (done) {
|
it('should throw on empty object', function (done) {
|
||||||
|
|
||||||
expect(function() {
|
expect(function () {
|
||||||
|
|
||||||
Joi.object().requiredKeys('a', 'c', 'b', 'd');
|
Joi.object().requiredKeys('a', 'c', 'b', 'd');
|
||||||
}).to.throw(Error, 'unknown key(s) a, b, c, d');
|
}).to.throw(Error, 'unknown key(s) a, b, c, d');
|
||||||
done();
|
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('Set', function () {
|
||||||
|
|
||||||
describe('#add', function () {
|
describe('#add', function () {
|
||||||
|
|
|
@ -133,6 +133,16 @@ describe('array', function () {
|
||||||
], done);
|
], 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) {
|
it('allows forbidden to restrict values', function (done) {
|
||||||
|
|
||||||
var schema = Joi.array().items(Joi.string().valid('four').forbidden(), Joi.string());
|
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 buffer = new Buffer('hello world');
|
||||||
var func = function() {};
|
var func = function () {};
|
||||||
var now = new Date();
|
var now = new Date();
|
||||||
var schema = Joi.array().sparse().unique();
|
var schema = Joi.array().sparse().unique();
|
||||||
|
|
||||||
Helper.validate(schema, [
|
Helper.validate(schema, [
|
||||||
[[2, 2], false],
|
[[2, 2], false],
|
||||||
[[02, 2], false],
|
[[02, 2], false], // eslint-disable-line no-octal
|
||||||
[[0x2, 2], false],
|
[[0x2, 2], false],
|
||||||
[['duplicate', 'duplicate'], false],
|
[['duplicate', 'duplicate'], false],
|
||||||
[[{ a: 'b' }, { a: 'b' }], false],
|
[[{ a: 'b' }, { a: 'b' }], false],
|
||||||
|
@ -606,7 +617,8 @@ describe('array', function () {
|
||||||
], done);
|
], 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();
|
var schema = Joi.array().unique();
|
||||||
|
|
||||||
Helper.validate(schema, [
|
Helper.validate(schema, [
|
||||||
|
@ -614,11 +626,12 @@ describe('array', function () {
|
||||||
], done);
|
], done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('validates without duplicates', function(done) {
|
it('validates without duplicates', function (done) {
|
||||||
|
|
||||||
var buffer = new Buffer('hello world');
|
var buffer = new Buffer('hello world');
|
||||||
var buffer2 = new Buffer('Hello world');
|
var buffer2 = new Buffer('Hello world');
|
||||||
var func = function() {};
|
var func = function () {};
|
||||||
var func2 = function() {};
|
var func2 = function () {};
|
||||||
var now = new Date();
|
var now = new Date();
|
||||||
var now2 = new Date(+now + 100);
|
var now2 = new Date(+now + 100);
|
||||||
var schema = Joi.array().unique();
|
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();
|
var schema = Joi.array().items(Joi.number()).items(Joi.boolean().forbidden()).single();
|
||||||
|
|
||||||
|
@ -706,7 +719,7 @@ describe('array', function () {
|
||||||
], done);
|
], 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();
|
var schema = Joi.array().items(Joi.number(), Joi.string()).single();
|
||||||
|
|
||||||
|
@ -719,7 +732,7 @@ describe('array', function () {
|
||||||
], done);
|
], 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();
|
var schema = Joi.array().items(Joi.array().items(Joi.number())).single();
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@ describe('date', function () {
|
||||||
], done);
|
], 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);
|
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);
|
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 schema = Joi.object({ a: Joi.date(), b: Joi.date().min(Joi.ref('a')) });
|
||||||
var now = Date.now();
|
var now = Date.now();
|
||||||
|
@ -125,14 +125,38 @@ describe('date', function () {
|
||||||
], done);
|
], 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, [
|
Helper.validate(schema, [
|
||||||
[{ a: 'abc', b: new Date() }, false, null, 'child "b" fails because ["b" references "a" which is not a date]'],
|
[{ b: now }, true, { context: { a: now } }],
|
||||||
[{ a: '123', b: new Date() }, true],
|
[{ b: now + 1e3 }, true, { context: { a: now } }],
|
||||||
[{ a: (Date.now() + 1e3).toString(), b: new Date() }, false, null, /^child "b" fails because \["b" must be larger than or equal to/]
|
[{ 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);
|
], done);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -152,30 +176,30 @@ describe('date', function () {
|
||||||
], done);
|
], 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(err).to.not.exist();
|
||||||
expect(value).to.deep.equal(past);
|
expect(value).to.deep.equal(past);
|
||||||
done();
|
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();
|
expect(err).to.exist();
|
||||||
done();
|
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 schema = Joi.object({ a: Joi.date(), b: Joi.date().max(Joi.ref('a')) });
|
||||||
var now = Date.now();
|
var now = Date.now();
|
||||||
|
@ -187,14 +211,39 @@ describe('date', function () {
|
||||||
], done);
|
], 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 schema = Joi.object({ a: Joi.string(), b: Joi.date().max(Joi.ref('a')) });
|
||||||
|
var now = Date.now();
|
||||||
|
|
||||||
Helper.validate(schema, [
|
Helper.validate(schema, [
|
||||||
[{ a: 'abc', b: new Date() }, false, null, 'child "b" fails because ["b" references "a" which is not a date]'],
|
[{ 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: '100000000000000', b: now }, true],
|
||||||
[{ a: (Date.now() - 1e3).toString(), b: new Date() }, false, null, /^child "b" fails because \["b" must be less than or equal to/]
|
[{ 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);
|
], done);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -208,7 +257,7 @@ describe('date', function () {
|
||||||
], done);
|
], done);
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#iso', function() {
|
describe('#iso', function () {
|
||||||
|
|
||||||
it('validates isoDate', function (done) {
|
it('validates isoDate', function (done) {
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ describe('errors', function () {
|
||||||
|
|
||||||
expect(err).to.exist();
|
expect(err).to.exist();
|
||||||
expect(err.name).to.equal('ValidationError');
|
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();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -288,7 +288,7 @@ describe('errors', function () {
|
||||||
|
|
||||||
it('annotates circular input', function (done) {
|
it('annotates circular input', function (done) {
|
||||||
|
|
||||||
var schema = {
|
var schema = {
|
||||||
x: Joi.object({
|
x: Joi.object({
|
||||||
y: Joi.object({
|
y: Joi.object({
|
||||||
z: Joi.number()
|
z: Joi.number()
|
||||||
|
@ -309,7 +309,7 @@ describe('errors', function () {
|
||||||
|
|
||||||
it('annotates deep circular input', function (done) {
|
it('annotates deep circular input', function (done) {
|
||||||
|
|
||||||
var schema = {
|
var schema = {
|
||||||
x: Joi.object({
|
x: Joi.object({
|
||||||
y: Joi.object({
|
y: Joi.object({
|
||||||
z: Joi.number()
|
z: Joi.number()
|
||||||
|
@ -330,7 +330,7 @@ describe('errors', function () {
|
||||||
|
|
||||||
it('annotates deep circular input with extra keys', function (done) {
|
it('annotates deep circular input with extra keys', function (done) {
|
||||||
|
|
||||||
var schema = {
|
var schema = {
|
||||||
x: Joi.object({
|
x: Joi.object({
|
||||||
y: Joi.object({
|
y: Joi.object({
|
||||||
z: Joi.number()
|
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({
|
var schema = Joi.object({
|
||||||
test: Joi.array().items(Joi.object().keys({
|
test: Joi.array().items(Joi.object().keys({
|
||||||
|
@ -1276,6 +1276,7 @@ describe('Joi', function () {
|
||||||
};
|
};
|
||||||
|
|
||||||
Joi.validate(value, schema, { abortEarly: false }, function (err, value) {
|
Joi.validate(value, schema, { abortEarly: false }, function (err, value) {
|
||||||
|
|
||||||
expect(err).to.exist();
|
expect(err).to.exist();
|
||||||
expect(err.details).to.have.length(6);
|
expect(err.details).to.have.length(6);
|
||||||
expect(err.details).to.deep.equal([{
|
expect(err.details).to.deep.equal([{
|
||||||
|
@ -1412,6 +1413,7 @@ describe('Joi', function () {
|
||||||
xor: Joi.string(),
|
xor: Joi.string(),
|
||||||
renamed: Joi.string().valid('456'),
|
renamed: Joi.string().valid('456'),
|
||||||
notEmpty: Joi.string().required().description('a').notes('b').tags('c'),
|
notEmpty: Joi.string().required().description('a').notes('b').tags('c'),
|
||||||
|
empty: Joi.string().empty('').strip(),
|
||||||
defaultRef: Joi.string().default(defaultRef, 'not here'),
|
defaultRef: Joi.string().default(defaultRef, 'not here'),
|
||||||
defaultFn: Joi.string().default(defaultFn, 'not here'),
|
defaultFn: Joi.string().default(defaultFn, 'not here'),
|
||||||
defaultDescribedFn: Joi.string().default(defaultDescribedFn, 'described test')
|
defaultDescribedFn: Joi.string().default(defaultDescribedFn, 'described test')
|
||||||
|
@ -1491,6 +1493,20 @@ describe('Joi', function () {
|
||||||
tags: ['c'],
|
tags: ['c'],
|
||||||
invalids: ['']
|
invalids: ['']
|
||||||
},
|
},
|
||||||
|
empty: {
|
||||||
|
type: 'string',
|
||||||
|
flags: {
|
||||||
|
empty: {
|
||||||
|
type: 'string',
|
||||||
|
flags: {
|
||||||
|
allowOnly: true
|
||||||
|
},
|
||||||
|
valids: ['']
|
||||||
|
},
|
||||||
|
strip: true
|
||||||
|
},
|
||||||
|
invalids: ['']
|
||||||
|
},
|
||||||
defaultRef: {
|
defaultRef: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
flags: {
|
flags: {
|
||||||
|
|
|
@ -70,7 +70,7 @@ describe('number', function () {
|
||||||
], done);
|
], done);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return false for Infinity', function(done) {
|
it('should return false for Infinity', function (done) {
|
||||||
|
|
||||||
var t = Joi.number();
|
var t = Joi.number();
|
||||||
Helper.validate(t, [
|
Helper.validate(t, [
|
||||||
|
@ -79,7 +79,7 @@ describe('number', function () {
|
||||||
], done);
|
], 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);
|
var t = Joi.number().allow(Infinity, -Infinity);
|
||||||
Helper.validate(t, [
|
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')) });
|
var schema = Joi.object({ a: Joi.number(), b: Joi.number().min(Joi.ref('a')) });
|
||||||
|
|
||||||
|
@ -553,7 +553,21 @@ describe('number', function () {
|
||||||
], done);
|
], 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')) });
|
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]']
|
[{ a: 'abc', b: 42 }, false, null, 'child "b" fails because ["b" references "a" which is not a number]']
|
||||||
], done);
|
], 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 () {
|
describe('#max', function () {
|
||||||
|
@ -574,7 +597,7 @@ describe('number', function () {
|
||||||
done();
|
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')) });
|
var schema = Joi.object({ a: Joi.number(), b: Joi.number().max(Joi.ref('a')) });
|
||||||
|
|
||||||
|
@ -589,7 +612,21 @@ describe('number', function () {
|
||||||
], done);
|
], 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')) });
|
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]']
|
[{ a: 'abc', b: 42 }, false, null, 'child "b" fails because ["b" references "a" which is not a number]']
|
||||||
], done);
|
], 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 () {
|
describe('#less', function () {
|
||||||
|
@ -610,7 +656,7 @@ describe('number', function () {
|
||||||
done();
|
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')) });
|
var schema = Joi.object({ a: Joi.number(), b: Joi.number().less(Joi.ref('a')) });
|
||||||
|
|
||||||
|
@ -625,7 +671,21 @@ describe('number', function () {
|
||||||
], done);
|
], 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')) });
|
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]']
|
[{ a: 'abc', b: 42 }, false, null, 'child "b" fails because ["b" references "a" which is not a number]']
|
||||||
], done);
|
], 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 () {
|
describe('#greater', function () {
|
||||||
|
@ -646,7 +715,7 @@ describe('number', function () {
|
||||||
done();
|
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')) });
|
var schema = Joi.object({ a: Joi.number(), b: Joi.number().greater(Joi.ref('a')) });
|
||||||
|
|
||||||
|
@ -661,7 +730,21 @@ describe('number', function () {
|
||||||
], done);
|
], 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')) });
|
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]']
|
[{ a: 'abc', b: 42 }, false, null, 'child "b" fails because ["b" references "a" which is not a number]']
|
||||||
], done);
|
], 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) {
|
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) {
|
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 });
|
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 });
|
var schema = Joi.object().rename('b', 'a', { ignoreUndefined: true, override: true });
|
||||||
|
|
||||||
|
|
|
@ -165,7 +165,7 @@ describe('string', function () {
|
||||||
], done);
|
], 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') });
|
var schema = Joi.object({ a: Joi.number(), b: Joi.string().min(Joi.ref('a'), 'utf8') });
|
||||||
Helper.validate(schema, [
|
Helper.validate(schema, [
|
||||||
|
@ -175,7 +175,17 @@ describe('string', function () {
|
||||||
], done);
|
], 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') });
|
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]']
|
[{ a: 'Hi there', b: '\u00bd' }, false, null, 'child "b" fails because ["b" references "a" which is not a number]']
|
||||||
], done);
|
], 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 () {
|
describe('#max', function () {
|
||||||
|
@ -223,7 +242,7 @@ describe('string', function () {
|
||||||
], done);
|
], 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') });
|
var schema = Joi.object({ a: Joi.number(), b: Joi.string().max(Joi.ref('a'), 'utf8') });
|
||||||
Helper.validate(schema, [
|
Helper.validate(schema, [
|
||||||
|
@ -233,7 +252,17 @@ describe('string', function () {
|
||||||
], done);
|
], 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') });
|
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]']
|
[{ a: 'Hi there', b: '\u00bd' }, false, null, 'child "b" fails because ["b" references "a" which is not a number]']
|
||||||
], done);
|
], 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 () {
|
describe('#creditCard', function () {
|
||||||
|
@ -318,7 +356,7 @@ describe('string', function () {
|
||||||
], done);
|
], 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') });
|
var schema = Joi.object({ a: Joi.number(), b: Joi.string().length(Joi.ref('a'), 'utf8') });
|
||||||
Helper.validate(schema, [
|
Helper.validate(schema, [
|
||||||
|
@ -328,7 +366,17 @@ describe('string', function () {
|
||||||
], done);
|
], 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') });
|
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]']
|
[{ a: 'Hi there', b: '\u00bd' }, false, null, 'child "b" fails because ["b" references "a" which is not a number]']
|
||||||
], done);
|
], 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) {
|
it('throws when options are not an object', function (done) {
|
||||||
|
|
||||||
expect(function () {
|
expect(function () {
|
||||||
|
|
||||||
var emailOptions = true;
|
var emailOptions = true;
|
||||||
|
@ -349,6 +408,7 @@ describe('string', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('throws when checkDNS option is enabled', function (done) {
|
it('throws when checkDNS option is enabled', function (done) {
|
||||||
|
|
||||||
expect(function () {
|
expect(function () {
|
||||||
|
|
||||||
var emailOptions = {checkDNS: true};
|
var emailOptions = {checkDNS: true};
|
||||||
|
@ -358,6 +418,7 @@ describe('string', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('throws when tldWhitelist is not an array or object', function (done) {
|
it('throws when tldWhitelist is not an array or object', function (done) {
|
||||||
|
|
||||||
expect(function () {
|
expect(function () {
|
||||||
|
|
||||||
var emailOptions = {tldWhitelist: 'domain.tld'};
|
var emailOptions = {tldWhitelist: 'domain.tld'};
|
||||||
|
@ -367,6 +428,7 @@ describe('string', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('throws when minDomainAtoms is not a number', function (done) {
|
it('throws when minDomainAtoms is not a number', function (done) {
|
||||||
|
|
||||||
expect(function () {
|
expect(function () {
|
||||||
|
|
||||||
var emailOptions = {minDomainAtoms: '1'};
|
var emailOptions = {minDomainAtoms: '1'};
|
||||||
|
@ -376,6 +438,7 @@ describe('string', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('throws when minDomainAtoms is not an integer', function (done) {
|
it('throws when minDomainAtoms is not an integer', function (done) {
|
||||||
|
|
||||||
expect(function () {
|
expect(function () {
|
||||||
|
|
||||||
var emailOptions = {minDomainAtoms: 1.2};
|
var emailOptions = {minDomainAtoms: 1.2};
|
||||||
|
@ -385,6 +448,7 @@ describe('string', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('throws when minDomainAtoms is not positive', function (done) {
|
it('throws when minDomainAtoms is not positive', function (done) {
|
||||||
|
|
||||||
expect(function () {
|
expect(function () {
|
||||||
|
|
||||||
var emailOptions = {minDomainAtoms: 0};
|
var emailOptions = {minDomainAtoms: 0};
|
||||||
|
@ -394,6 +458,7 @@ describe('string', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not throw when minDomainAtoms is a positive integer', function (done) {
|
it('does not throw when minDomainAtoms is a positive integer', function (done) {
|
||||||
|
|
||||||
expect(function () {
|
expect(function () {
|
||||||
|
|
||||||
var emailOptions = {minDomainAtoms: 1};
|
var emailOptions = {minDomainAtoms: 1};
|
||||||
|
@ -403,6 +468,7 @@ describe('string', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('throws when errorLevel is not an integer or boolean', function (done) {
|
it('throws when errorLevel is not an integer or boolean', function (done) {
|
||||||
|
|
||||||
expect(function () {
|
expect(function () {
|
||||||
|
|
||||||
var emailOptions = {errorLevel: 1.2};
|
var emailOptions = {errorLevel: 1.2};
|
||||||
|
@ -412,6 +478,7 @@ describe('string', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('throws when errorLevel is negative', function (done) {
|
it('throws when errorLevel is negative', function (done) {
|
||||||
|
|
||||||
expect(function () {
|
expect(function () {
|
||||||
|
|
||||||
var emailOptions = {errorLevel: -1};
|
var emailOptions = {errorLevel: -1};
|
||||||
|
@ -421,6 +488,7 @@ describe('string', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not throw when errorLevel is 0', function (done) {
|
it('does not throw when errorLevel is 0', function (done) {
|
||||||
|
|
||||||
expect(function () {
|
expect(function () {
|
||||||
|
|
||||||
var emailOptions = {errorLevel: 0};
|
var emailOptions = {errorLevel: 0};
|
||||||
|
@ -653,7 +721,7 @@ describe('string', function () {
|
||||||
['v1.09azAZ-._~!$&\'()*+,;=:/33', false],
|
['v1.09azAZ-._~!$&\'()*+,;=:/33', false],
|
||||||
['v1.09#', false]
|
['v1.09#', false]
|
||||||
],
|
],
|
||||||
validIPv4sWithCidr = function(success) {
|
validIPv4sWithCidr = function (success) {
|
||||||
|
|
||||||
return [
|
return [
|
||||||
['0.0.0.0/32', success],
|
['0.0.0.0/32', success],
|
||||||
|
@ -672,7 +740,7 @@ describe('string', function () {
|
||||||
['000.000.000.000/32', success]
|
['000.000.000.000/32', success]
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
validIPv4sWithoutCidr = function(success) {
|
validIPv4sWithoutCidr = function (success) {
|
||||||
|
|
||||||
return [
|
return [
|
||||||
['0.0.0.0', success],
|
['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();
|
var schema = Joi.string().ip();
|
||||||
Helper.validate(schema, []
|
Helper.validate(schema, []
|
||||||
|
@ -740,7 +808,7 @@ describe('string', function () {
|
||||||
.concat(invalidIPvFutures), done);
|
.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' });
|
var schema = Joi.string().ip({ cidr: 'optional' });
|
||||||
Helper.validate(schema, []
|
Helper.validate(schema, []
|
||||||
|
@ -756,7 +824,7 @@ describe('string', function () {
|
||||||
.concat(invalidIPvFutures), done);
|
.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' });
|
var schema = Joi.string().ip({ cidr: 'required' });
|
||||||
Helper.validate(schema, []
|
Helper.validate(schema, []
|
||||||
|
@ -772,7 +840,7 @@ describe('string', function () {
|
||||||
.concat(invalidIPvFutures), done);
|
.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' });
|
var schema = Joi.string().ip({ cidr: 'forbidden' });
|
||||||
Helper.validate(schema, []
|
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' });
|
var schema = Joi.string().ip({ version: 'ipv4' });
|
||||||
Helper.validate(schema, []
|
Helper.validate(schema, []
|
||||||
|
@ -890,7 +958,7 @@ describe('string', function () {
|
||||||
.concat(invalidIPvFutures), done);
|
.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' });
|
var schema = Joi.string().ip({ version: 'ipv4', cidr: 'optional' });
|
||||||
Helper.validate(schema, []
|
Helper.validate(schema, []
|
||||||
|
@ -906,7 +974,7 @@ describe('string', function () {
|
||||||
.concat(invalidIPvFutures), done);
|
.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' });
|
var schema = Joi.string().ip({ version: 'ipv4', cidr: 'required' });
|
||||||
Helper.validate(schema, []
|
Helper.validate(schema, []
|
||||||
|
@ -922,7 +990,7 @@ describe('string', function () {
|
||||||
.concat(invalidIPvFutures), done);
|
.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' });
|
var schema = Joi.string().ip({ version: 'ipv4', cidr: 'forbidden' });
|
||||||
Helper.validate(schema, []
|
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' });
|
var schema = Joi.string().ip({ version: 'ipv6' });
|
||||||
Helper.validate(schema, []
|
Helper.validate(schema, []
|
||||||
|
@ -957,7 +1025,7 @@ describe('string', function () {
|
||||||
.concat(invalidIPvFutures), done);
|
.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' });
|
var schema = Joi.string().ip({ version: 'ipv6', cidr: 'optional' });
|
||||||
Helper.validate(schema, []
|
Helper.validate(schema, []
|
||||||
|
@ -973,7 +1041,7 @@ describe('string', function () {
|
||||||
.concat(invalidIPvFutures), done);
|
.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' });
|
var schema = Joi.string().ip({ version: 'ipv6', cidr: 'required' });
|
||||||
Helper.validate(schema, []
|
Helper.validate(schema, []
|
||||||
|
@ -989,7 +1057,7 @@ describe('string', function () {
|
||||||
.concat(invalidIPvFutures), done);
|
.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' });
|
var schema = Joi.string().ip({ version: 'ipv6', cidr: 'forbidden' });
|
||||||
Helper.validate(schema, []
|
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' });
|
var schema = Joi.string().ip({ version: 'ipvfuture' });
|
||||||
Helper.validate(schema, []
|
Helper.validate(schema, []
|
||||||
|
@ -1024,7 +1092,7 @@ describe('string', function () {
|
||||||
.concat(invalidIPvFutures), done);
|
.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' });
|
var schema = Joi.string().ip({ version: 'ipvfuture', cidr: 'optional' });
|
||||||
Helper.validate(schema, []
|
Helper.validate(schema, []
|
||||||
|
@ -1040,7 +1108,7 @@ describe('string', function () {
|
||||||
.concat(invalidIPvFutures), done);
|
.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' });
|
var schema = Joi.string().ip({ version: 'ipvfuture', cidr: 'required' });
|
||||||
Helper.validate(schema, []
|
Helper.validate(schema, []
|
||||||
|
@ -1056,7 +1124,7 @@ describe('string', function () {
|
||||||
.concat(invalidIPvFutures), done);
|
.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' });
|
var schema = Joi.string().ip({ version: 'ipvfuture', cidr: 'forbidden' });
|
||||||
Helper.validate(schema, []
|
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' ] });
|
var schema = Joi.string().ip({ version: [ 'ipv4', 'ipv6' ] });
|
||||||
Helper.validate(schema, []
|
Helper.validate(schema, []
|
||||||
|
@ -1091,7 +1159,7 @@ describe('string', function () {
|
||||||
.concat(invalidIPvFutures), done);
|
.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' });
|
var schema = Joi.string().ip({ version: [ 'ipv4', 'ipv6' ], cidr: 'optional' });
|
||||||
Helper.validate(schema, []
|
Helper.validate(schema, []
|
||||||
|
@ -1107,7 +1175,7 @@ describe('string', function () {
|
||||||
.concat(invalidIPvFutures), done);
|
.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' });
|
var schema = Joi.string().ip({ version: [ 'ipv4', 'ipv6' ], cidr: 'required' });
|
||||||
Helper.validate(schema, []
|
Helper.validate(schema, []
|
||||||
|
@ -1123,7 +1191,7 @@ describe('string', function () {
|
||||||
.concat(invalidIPvFutures), done);
|
.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' });
|
var schema = Joi.string().ip({ version: [ 'ipv4', 'ipv6' ], cidr: 'forbidden' });
|
||||||
Helper.validate(schema, []
|
Helper.validate(schema, []
|
||||||
|
@ -1503,6 +1571,7 @@ describe('string', function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('validates combination of null allowed and max', function (done) {
|
it('validates combination of null allowed and max', function (done) {
|
||||||
|
|
||||||
var rule = Joi.string().allow(null).max(3);
|
var rule = Joi.string().allow(null).max(3);
|
||||||
Helper.validate(rule, [
|
Helper.validate(rule, [
|
||||||
['x', true],
|
['x', true],
|
||||||
|
@ -1904,7 +1973,7 @@ describe('string', function () {
|
||||||
['file:///whatever', true],
|
['file:///whatever', true],
|
||||||
['mailto:asdf@asdf.com', true],
|
['mailto:asdf@asdf.com', true],
|
||||||
['ftp://www.example.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],
|
['xmpp:isaacschlueter@jabber.org', true],
|
||||||
['f://some.host/path', true],
|
['f://some.host/path', true],
|
||||||
['http://localhost:18/asdf', true],
|
['http://localhost:18/asdf', true],
|
||||||
|
@ -1934,7 +2003,7 @@ describe('string', function () {
|
||||||
['dash-test://foo/bar', true],
|
['dash-test://foo/bar', true],
|
||||||
['xmpp:isaacschlueter@jabber.org', true],
|
['xmpp:isaacschlueter@jabber.org', true],
|
||||||
['http://atpass:foo%40bar@127.0.0.1:8080/path?search=foo#bar', 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://localhost/etc/node/', true],
|
||||||
['file:///etc/node/', true],
|
['file:///etc/node/', true],
|
||||||
['http://USER:PW@www.ExAmPlE.com/', 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
|
3.2.7 / 2015-02-19
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
|
|
|
@ -175,6 +175,8 @@ options:
|
||||||
block to flow style for collections. -1 means block style everwhere
|
block to flow style for collections. -1 means block style everwhere
|
||||||
- `styles` - "tag" => "style" map. Each tag may have own set of styles.
|
- `styles` - "tag" => "style" map. Each tag may have own set of styles.
|
||||||
- `schema` _(default: `DEFAULT_SAFE_SCHEMA`)_ specifies a schema to use.
|
- `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:
|
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';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
|
@ -44,12 +44,12 @@ module.exports.addConstructor = deprecated('addConstructor');
|
||||||
|
|
||||||
|
|
||||||
function isNothing(subject) {
|
function isNothing(subject) {
|
||||||
return (undefined === subject) || (null === subject);
|
return (typeof subject === 'undefined') || (null === subject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function isObject(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;
|
return sequence;
|
||||||
} else if (isNothing(sequence)) {
|
} else if (isNothing(sequence)) {
|
||||||
return [];
|
return [];
|
||||||
} else {
|
|
||||||
return [ sequence ];
|
|
||||||
}
|
}
|
||||||
|
return [ sequence ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -106,17 +105,16 @@ module.exports.extend = extend;
|
||||||
},{}],3:[function(require,module,exports){
|
},{}],3:[function(require,module,exports){
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
/*eslint-disable no-use-before-define*/
|
||||||
|
|
||||||
var common = require('./common');
|
var common = require('./common');
|
||||||
var YAMLException = require('./exception');
|
var YAMLException = require('./exception');
|
||||||
var DEFAULT_FULL_SCHEMA = require('./schema/default_full');
|
var DEFAULT_FULL_SCHEMA = require('./schema/default_full');
|
||||||
var DEFAULT_SAFE_SCHEMA = require('./schema/default_safe');
|
var DEFAULT_SAFE_SCHEMA = require('./schema/default_safe');
|
||||||
|
|
||||||
|
|
||||||
var _toString = Object.prototype.toString;
|
var _toString = Object.prototype.toString;
|
||||||
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||||
|
|
||||||
|
|
||||||
var CHAR_TAB = 0x09; /* Tab */
|
var CHAR_TAB = 0x09; /* Tab */
|
||||||
var CHAR_LINE_FEED = 0x0A; /* LF */
|
var CHAR_LINE_FEED = 0x0A; /* LF */
|
||||||
var CHAR_CARRIAGE_RETURN = 0x0D; /* CR */
|
var CHAR_CARRIAGE_RETURN = 0x0D; /* CR */
|
||||||
|
@ -141,7 +139,6 @@ var CHAR_LEFT_CURLY_BRACKET = 0x7B; /* { */
|
||||||
var CHAR_VERTICAL_LINE = 0x7C; /* | */
|
var CHAR_VERTICAL_LINE = 0x7C; /* | */
|
||||||
var CHAR_RIGHT_CURLY_BRACKET = 0x7D; /* } */
|
var CHAR_RIGHT_CURLY_BRACKET = 0x7D; /* } */
|
||||||
|
|
||||||
|
|
||||||
var ESCAPE_SEQUENCES = {};
|
var ESCAPE_SEQUENCES = {};
|
||||||
|
|
||||||
ESCAPE_SEQUENCES[0x00] = '\\0';
|
ESCAPE_SEQUENCES[0x00] = '\\0';
|
||||||
|
@ -160,13 +157,11 @@ ESCAPE_SEQUENCES[0xA0] = '\\_';
|
||||||
ESCAPE_SEQUENCES[0x2028] = '\\L';
|
ESCAPE_SEQUENCES[0x2028] = '\\L';
|
||||||
ESCAPE_SEQUENCES[0x2029] = '\\P';
|
ESCAPE_SEQUENCES[0x2029] = '\\P';
|
||||||
|
|
||||||
|
|
||||||
var DEPRECATED_BOOLEANS_SYNTAX = [
|
var DEPRECATED_BOOLEANS_SYNTAX = [
|
||||||
'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON',
|
'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON',
|
||||||
'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF'
|
'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
function compileStyleMap(schema, map) {
|
function compileStyleMap(schema, map) {
|
||||||
var result, keys, index, length, tag, style, type;
|
var result, keys, index, length, tag, style, type;
|
||||||
|
|
||||||
|
@ -197,7 +192,6 @@ function compileStyleMap(schema, map) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function encodeHex(character) {
|
function encodeHex(character) {
|
||||||
var string, handle, length;
|
var string, handle, length;
|
||||||
|
|
||||||
|
@ -219,13 +213,13 @@ function encodeHex(character) {
|
||||||
return '\\' + handle + common.repeat('0', length - string.length) + string;
|
return '\\' + handle + common.repeat('0', length - string.length) + string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function State(options) {
|
function State(options) {
|
||||||
this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
|
this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
|
||||||
this.indent = Math.max(1, (options['indent'] || 2));
|
this.indent = Math.max(1, (options['indent'] || 2));
|
||||||
this.skipInvalid = options['skipInvalid'] || false;
|
this.skipInvalid = options['skipInvalid'] || false;
|
||||||
this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']);
|
this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']);
|
||||||
this.styleMap = compileStyleMap(this.schema, options['styles'] || null);
|
this.styleMap = compileStyleMap(this.schema, options['styles'] || null);
|
||||||
|
this.sortKeys = options['sortKeys'] || false;
|
||||||
|
|
||||||
this.implicitTypes = this.schema.compiledImplicit;
|
this.implicitTypes = this.schema.compiledImplicit;
|
||||||
this.explicitTypes = this.schema.compiledExplicit;
|
this.explicitTypes = this.schema.compiledExplicit;
|
||||||
|
@ -237,6 +231,31 @@ function State(options) {
|
||||||
this.usedDuplicates = null;
|
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) {
|
function generateNextLine(state, level) {
|
||||||
return '\n' + common.repeat(' ', state.indent * level);
|
return '\n' + common.repeat(' ', state.indent * level);
|
||||||
|
@ -256,81 +275,339 @@ function testImplicitResolving(state, str) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function writeScalar(state, object) {
|
function StringBuilder(source) {
|
||||||
var isQuoted, checkpoint, position, length, character, first;
|
this.source = source;
|
||||||
|
this.result = '';
|
||||||
|
this.checkpoint = 0;
|
||||||
|
}
|
||||||
|
|
||||||
state.dump = '';
|
StringBuilder.prototype.takeUpTo = function (position) {
|
||||||
isQuoted = false;
|
var er;
|
||||||
checkpoint = 0;
|
|
||||||
first = object.charCodeAt(0) || 0;
|
|
||||||
|
|
||||||
if (-1 !== DEPRECATED_BOOLEANS_SYNTAX.indexOf(object)) {
|
if (position < this.checkpoint) {
|
||||||
// Ensure compatibility with YAML 1.0/1.1 loaders.
|
er = new Error('position should be > checkpoint');
|
||||||
isQuoted = true;
|
er.position = position;
|
||||||
} else if (0 === object.length) {
|
er.checkpoint = this.checkpoint;
|
||||||
// Quote empty string
|
throw er;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (position = 0, length = object.length; position < length; position += 1) {
|
this.result += this.source.slice(this.checkpoint, position);
|
||||||
character = object.charCodeAt(position);
|
this.checkpoint = position;
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
if (!isQuoted) {
|
StringBuilder.prototype.escapeChar = function () {
|
||||||
if (CHAR_TAB === character ||
|
var character, esc;
|
||||||
CHAR_LINE_FEED === character ||
|
|
||||||
CHAR_CARRIAGE_RETURN === character ||
|
character = this.source.charCodeAt(this.checkpoint);
|
||||||
CHAR_COMMA === character ||
|
esc = ESCAPE_SEQUENCES[character] || encodeHex(character);
|
||||||
CHAR_LEFT_SQUARE_BRACKET === character ||
|
this.result += esc;
|
||||||
CHAR_RIGHT_SQUARE_BRACKET === character ||
|
this.checkpoint += 1;
|
||||||
CHAR_LEFT_CURLY_BRACKET === character ||
|
|
||||||
CHAR_RIGHT_CURLY_BRACKET === character ||
|
return this;
|
||||||
CHAR_SHARP === character ||
|
};
|
||||||
CHAR_AMPERSAND === character ||
|
|
||||||
CHAR_ASTERISK === character ||
|
StringBuilder.prototype.finish = function () {
|
||||||
CHAR_EXCLAMATION === character ||
|
if (this.source.length > this.checkpoint) {
|
||||||
CHAR_VERTICAL_LINE === character ||
|
this.takeUpTo(this.source.length);
|
||||||
CHAR_GREATER_THAN === character ||
|
}
|
||||||
CHAR_SINGLE_QUOTE === character ||
|
};
|
||||||
CHAR_DOUBLE_QUOTE === character ||
|
|
||||||
CHAR_PERCENT === character ||
|
function writeScalar(state, object, level) {
|
||||||
CHAR_COMMERCIAL_AT === character ||
|
var simple, first, spaceWrap, folded, literal, single, double,
|
||||||
CHAR_COLON === character ||
|
sawLineFeed, linePosition, longestLine, indent, max, character,
|
||||||
CHAR_GRAVE_ACCENT === character) {
|
position, escapeSeq, hexEsc, previous, lineLength, modifier,
|
||||||
isQuoted = true;
|
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] ||
|
if (single && character === CHAR_SINGLE_QUOTE) {
|
||||||
!((0x00020 <= character && character <= 0x00007E) ||
|
single = false;
|
||||||
(0x00085 === character) ||
|
}
|
||||||
(0x000A0 <= character && character <= 0x00D7FF) ||
|
|
||||||
(0x0E000 <= character && character <= 0x00FFFD) ||
|
escapeSeq = ESCAPE_SEQUENCES[character];
|
||||||
(0x10000 <= character && character <= 0x10FFFF))) {
|
hexEsc = needsHexEscape(character);
|
||||||
state.dump += object.slice(checkpoint, position);
|
|
||||||
state.dump += ESCAPE_SEQUENCES[character] || encodeHex(character);
|
if (!escapeSeq && !hexEsc) {
|
||||||
checkpoint = position + 1;
|
continue;
|
||||||
isQuoted = true;
|
}
|
||||||
|
|
||||||
|
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) {
|
if (literal && longestLine < max) {
|
||||||
state.dump += object.slice(checkpoint, position);
|
folded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isQuoted && testImplicitResolving(state, state.dump)) {
|
// If it's literally one line, then don't bother with the literal.
|
||||||
isQuoted = true;
|
// We may still want to do a fold, though, if it's a super long line.
|
||||||
|
if (!sawLineFeed) {
|
||||||
|
literal = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isQuoted) {
|
if (simple) {
|
||||||
state.dump = '"' + state.dump + '"';
|
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) {
|
function writeFlowSequence(state, level, object) {
|
||||||
|
@ -428,6 +705,18 @@ function writeBlockMapping(state, level, object, compact) {
|
||||||
explicitPair,
|
explicitPair,
|
||||||
pairBuffer;
|
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) {
|
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
||||||
pairBuffer = '';
|
pairBuffer = '';
|
||||||
|
|
||||||
|
@ -576,11 +865,12 @@ function writeNode(state, level, object, block, compact) {
|
||||||
}
|
}
|
||||||
} else if ('[object String]' === type) {
|
} else if ('[object String]' === type) {
|
||||||
if ('?' !== state.tag) {
|
if ('?' !== state.tag) {
|
||||||
writeScalar(state, state.dump);
|
writeScalar(state, state.dump, level);
|
||||||
}
|
}
|
||||||
} else if (state.skipInvalid) {
|
|
||||||
return false;
|
|
||||||
} else {
|
} else {
|
||||||
|
if (state.skipInvalid) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
throw new YAMLException('unacceptable kind of an object to dump ' + type);
|
throw new YAMLException('unacceptable kind of an object to dump ' + type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -620,8 +910,8 @@ function inspectNode(object, objects, duplicatesIndexes) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
objects.push(object);
|
objects.push(object);
|
||||||
|
|
||||||
if(Array.isArray(object)) {
|
if (Array.isArray(object)) {
|
||||||
for (index = 0, length = object.length; index < length; index += 1) {
|
for (index = 0, length = object.length; index < length; index += 1) {
|
||||||
inspectNode(object[index], objects, duplicatesIndexes);
|
inspectNode(object[index], objects, duplicatesIndexes);
|
||||||
}
|
}
|
||||||
|
@ -645,17 +935,14 @@ function dump(input, options) {
|
||||||
|
|
||||||
if (writeNode(state, 0, input, true, true)) {
|
if (writeNode(state, 0, input, true, true)) {
|
||||||
return state.dump + '\n';
|
return state.dump + '\n';
|
||||||
} else {
|
|
||||||
return '';
|
|
||||||
}
|
}
|
||||||
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function safeDump(input, options) {
|
function safeDump(input, options) {
|
||||||
return dump(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
|
return dump(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
module.exports.dump = dump;
|
module.exports.dump = dump;
|
||||||
module.exports.safeDump = safeDump;
|
module.exports.safeDump = safeDump;
|
||||||
|
|
||||||
|
@ -689,6 +976,7 @@ module.exports = YAMLException;
|
||||||
},{}],5:[function(require,module,exports){
|
},{}],5:[function(require,module,exports){
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
/*eslint-disable max-len,no-use-before-define*/
|
||||||
|
|
||||||
var common = require('./common');
|
var common = require('./common');
|
||||||
var YAMLException = require('./exception');
|
var YAMLException = require('./exception');
|
||||||
|
@ -711,7 +999,7 @@ var CHOMPING_STRIP = 2;
|
||||||
var CHOMPING_KEEP = 3;
|
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_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
|
||||||
var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
|
var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
|
||||||
var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
|
var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
|
||||||
|
@ -748,7 +1036,9 @@ function fromHexCode(c) {
|
||||||
return c - 0x30;
|
return c - 0x30;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*eslint-disable no-bitwise*/
|
||||||
lc = c | 0x20;
|
lc = c | 0x20;
|
||||||
|
|
||||||
if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) {
|
if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) {
|
||||||
return lc - 0x61 + 10;
|
return lc - 0x61 + 10;
|
||||||
}
|
}
|
||||||
|
@ -772,7 +1062,7 @@ function fromDecimalCode(c) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function simpleEscapeSequence(c) {
|
function simpleEscapeSequence(c) {
|
||||||
return (c === 0x30/* 0 */) ? '\x00' :
|
return (c === 0x30/* 0 */) ? '\x00' :
|
||||||
(c === 0x61/* a */) ? '\x07' :
|
(c === 0x61/* a */) ? '\x07' :
|
||||||
(c === 0x62/* b */) ? '\x08' :
|
(c === 0x62/* b */) ? '\x08' :
|
||||||
(c === 0x74/* t */) ? '\x09' :
|
(c === 0x74/* t */) ? '\x09' :
|
||||||
|
@ -795,12 +1085,11 @@ function simpleEscapeSequence(c) {
|
||||||
function charFromCodepoint(c) {
|
function charFromCodepoint(c) {
|
||||||
if (c <= 0xFFFF) {
|
if (c <= 0xFFFF) {
|
||||||
return String.fromCharCode(c);
|
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
|
var simpleEscapeCheck = new Array(256); // integer, for fast access
|
||||||
|
@ -866,7 +1155,7 @@ function throwWarning(state, message) {
|
||||||
|
|
||||||
var directiveHandlers = {
|
var directiveHandlers = {
|
||||||
|
|
||||||
'YAML': function handleYamlDirective(state, name, args) {
|
YAML: function handleYamlDirective(state, name, args) {
|
||||||
|
|
||||||
var match, major, minor;
|
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;
|
var handle, prefix;
|
||||||
|
|
||||||
|
@ -1059,7 +1348,7 @@ function testDocumentSeparator(state) {
|
||||||
// in parent on each call, for efficiency. No needs to test here again.
|
// in parent on each call, for efficiency. No needs to test here again.
|
||||||
if ((0x2D/* - */ === ch || 0x2E/* . */ === ch) &&
|
if ((0x2D/* - */ === ch || 0x2E/* . */ === ch) &&
|
||||||
state.input.charCodeAt(_position + 1) === ch &&
|
state.input.charCodeAt(_position + 1) === ch &&
|
||||||
state.input.charCodeAt(_position+ 2) === ch) {
|
state.input.charCodeAt(_position + 2) === ch) {
|
||||||
|
|
||||||
_position += 3;
|
_position += 3;
|
||||||
|
|
||||||
|
@ -1129,7 +1418,7 @@ function readPlainScalar(state, nodeIndent, withinFlowCollection) {
|
||||||
|
|
||||||
while (0 !== ch) {
|
while (0 !== ch) {
|
||||||
if (0x3A/* : */ === ch) {
|
if (0x3A/* : */ === ch) {
|
||||||
following = state.input.charCodeAt(state.position+1);
|
following = state.input.charCodeAt(state.position + 1);
|
||||||
|
|
||||||
if (is_WS_OR_EOL(following) ||
|
if (is_WS_OR_EOL(following) ||
|
||||||
withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
||||||
|
@ -1184,11 +1473,11 @@ function readPlainScalar(state, nodeIndent, withinFlowCollection) {
|
||||||
|
|
||||||
if (state.result) {
|
if (state.result) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
state.kind = _kind;
|
|
||||||
state.result = _result;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
state.kind = _kind;
|
||||||
|
state.result = _result;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function readSingleQuotedScalar(state, nodeIndent) {
|
function readSingleQuotedScalar(state, nodeIndent) {
|
||||||
|
@ -1267,7 +1556,7 @@ function readDoubleQuotedScalar(state, nodeIndent) {
|
||||||
if (is_EOL(ch)) {
|
if (is_EOL(ch)) {
|
||||||
skipSeparationSpace(state, false, nodeIndent);
|
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]) {
|
} else if (ch < 256 && simpleEscapeCheck[ch]) {
|
||||||
state.result += simpleEscapeMap[ch];
|
state.result += simpleEscapeMap[ch];
|
||||||
state.position++;
|
state.position++;
|
||||||
|
@ -1333,11 +1622,11 @@ function readFlowCollection(state, nodeIndent) {
|
||||||
ch = state.input.charCodeAt(state.position);
|
ch = state.input.charCodeAt(state.position);
|
||||||
|
|
||||||
if (ch === 0x5B/* [ */) {
|
if (ch === 0x5B/* [ */) {
|
||||||
terminator = 0x5D/* ] */;
|
terminator = 0x5D;/* ] */
|
||||||
isMapping = false;
|
isMapping = false;
|
||||||
_result = [];
|
_result = [];
|
||||||
} else if (ch === 0x7B/* { */) {
|
} else if (ch === 0x7B/* { */) {
|
||||||
terminator = 0x7D/* } */;
|
terminator = 0x7D;/* } */
|
||||||
isMapping = true;
|
isMapping = true;
|
||||||
_result = {};
|
_result = {};
|
||||||
} else {
|
} else {
|
||||||
|
@ -1539,24 +1828,20 @@ function readBlockScalar(state, nodeIndent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Literal style: just add exact number of line breaks between content lines.
|
// 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 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.
|
// In case of the first content line - count only empty lines.
|
||||||
} else {
|
|
||||||
state.result += common.repeat('\n', emptyLines);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
detectedIndent = true;
|
detectedIndent = true;
|
||||||
emptyLines = 0;
|
emptyLines = 0;
|
||||||
captureStart = state.position;
|
captureStart = state.position;
|
||||||
|
|
||||||
while (!is_EOL(ch) && (0 !== ch))
|
while (!is_EOL(ch) && (0 !== ch)) {
|
||||||
{ ch = state.input.charCodeAt(++state.position); }
|
ch = state.input.charCodeAt(++state.position);
|
||||||
|
}
|
||||||
|
|
||||||
captureSegment(state, captureStart, state.position, false);
|
captureSegment(state, captureStart, state.position, false);
|
||||||
}
|
}
|
||||||
|
@ -1622,9 +1907,8 @@ function readBlockSequence(state, nodeIndent) {
|
||||||
state.kind = 'sequence';
|
state.kind = 'sequence';
|
||||||
state.result = _result;
|
state.result = _result;
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function readBlockMapping(state, nodeIndent, flowIndent) {
|
function readBlockMapping(state, nodeIndent, flowIndent) {
|
||||||
|
@ -2204,10 +2488,18 @@ function loadDocuments(input, options) {
|
||||||
input = String(input);
|
input = String(input);
|
||||||
options = options || {};
|
options = options || {};
|
||||||
|
|
||||||
if (0 !== input.length &&
|
if (input.length !== 0) {
|
||||||
0x0A/* LF */ !== input.charCodeAt(input.length - 1) &&
|
|
||||||
0x0D/* CR */ !== input.charCodeAt(input.length - 1)) {
|
// Add tailing `\n` if not exists
|
||||||
input += '\n';
|
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);
|
var state = new State(input, options);
|
||||||
|
@ -2245,12 +2537,12 @@ function load(input, options) {
|
||||||
var documents = loadDocuments(input, options), index, length;
|
var documents = loadDocuments(input, options), index, length;
|
||||||
|
|
||||||
if (0 === documents.length) {
|
if (0 === documents.length) {
|
||||||
|
/*eslint-disable no-undefined*/
|
||||||
return undefined;
|
return undefined;
|
||||||
} else if (1 === documents.length) {
|
} else if (1 === documents.length) {
|
||||||
return documents[0];
|
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){
|
},{"./common":2}],7:[function(require,module,exports){
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
/*eslint-disable max-len*/
|
||||||
|
|
||||||
var common = require('./common');
|
var common = require('./common');
|
||||||
var YAMLException = require('./exception');
|
var YAMLException = require('./exception');
|
||||||
|
@ -2643,6 +2936,7 @@ module.exports = Type;
|
||||||
},{"./exception":4}],14:[function(require,module,exports){
|
},{"./exception":4}],14:[function(require,module,exports){
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
/*eslint-disable no-bitwise*/
|
||||||
|
|
||||||
// A trick for browserified version.
|
// A trick for browserified version.
|
||||||
// Since we make browserifier to ignore `buffer` module, NodeBuffer will be undefined
|
// 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;
|
var code, idx, bitlen = 0, len = 0, max = data.length, map = BASE64_MAP;
|
||||||
|
|
||||||
// Convert one by one.
|
// Convert one by one.
|
||||||
for (idx = 0; idx < max; idx ++) {
|
for (idx = 0; idx < max; idx++) {
|
||||||
code = map.indexOf(data.charAt(idx));
|
code = map.indexOf(data.charAt(idx));
|
||||||
|
|
||||||
// Skip CR/LF
|
// Skip CR/LF
|
||||||
|
@ -2700,7 +2994,7 @@ function constructYamlBinary(data) {
|
||||||
|
|
||||||
// Dump tail
|
// Dump tail
|
||||||
|
|
||||||
tailbits = (max % 4)*6;
|
tailbits = (max % 4) * 6;
|
||||||
|
|
||||||
if (tailbits === 0) {
|
if (tailbits === 0) {
|
||||||
result.push((bits >> 16) & 0xFF);
|
result.push((bits >> 16) & 0xFF);
|
||||||
|
@ -2872,9 +3166,8 @@ function constructYamlFloat(data) {
|
||||||
|
|
||||||
return sign * value;
|
return sign * value;
|
||||||
|
|
||||||
} else {
|
|
||||||
return sign * parseFloat(value, 10);
|
|
||||||
}
|
}
|
||||||
|
return sign * parseFloat(value, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
function representYamlFloat(object, style) {
|
function representYamlFloat(object, style) {
|
||||||
|
@ -2907,9 +3200,8 @@ function representYamlFloat(object, style) {
|
||||||
}
|
}
|
||||||
} else if (common.isNegativeZero(object)) {
|
} else if (common.isNegativeZero(object)) {
|
||||||
return '-0.0';
|
return '-0.0';
|
||||||
} else {
|
|
||||||
return object.toString(10);
|
|
||||||
}
|
}
|
||||||
|
return object.toString(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isFloat(object) {
|
function isFloat(object) {
|
||||||
|
@ -2967,7 +3259,7 @@ function resolveYamlInteger(data) {
|
||||||
|
|
||||||
if (ch === '0') {
|
if (ch === '0') {
|
||||||
// 0
|
// 0
|
||||||
if (index+1 === max) { return true; }
|
if (index + 1 === max) { return true; }
|
||||||
ch = data[++index];
|
ch = data[++index];
|
||||||
|
|
||||||
// base 2, base 8, base 16
|
// base 2, base 8, base 16
|
||||||
|
@ -3179,7 +3471,8 @@ function constructJavascriptFunction(data) {
|
||||||
|
|
||||||
// Esprima's ranges include the first '{' and the last '}' characters on
|
// Esprima's ranges include the first '{' and the last '}' characters on
|
||||||
// function expressions. So cut them out.
|
// 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*/) {
|
function representJavascriptFunction(object /*, style*/) {
|
||||||
|
@ -3294,6 +3587,7 @@ function resolveJavascriptUndefined() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function constructJavascriptUndefined() {
|
function constructJavascriptUndefined() {
|
||||||
|
/*eslint-disable no-undefined*/
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
/*eslint-disable no-console*/
|
||||||
|
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
|
@ -78,23 +79,23 @@ var SpaceYamlType = new yaml.Type('!space', {
|
||||||
|
|
||||||
var SPACE_SCHEMA = yaml.Schema.create([ SpaceYamlType, PointYamlType ]);
|
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.
|
// And read a document using that schema.
|
||||||
|
fs.readFile(path.join(__dirname, 'custom_types.yml'), 'utf8', function (error, data) {
|
||||||
fs.readFile(path.join(__dirname, 'custom_types.yml'), 'utf8', function (error, data) {
|
var loaded;
|
||||||
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));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
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.
|
// There are some exports to play with this example interactively.
|
||||||
|
|
||||||
module.exports.Point = Point;
|
module.exports.Point = Point;
|
||||||
module.exports.Space = Space;
|
module.exports.Space = Space;
|
||||||
module.exports.PointYamlType = PointYamlType;
|
module.exports.PointYamlType = PointYamlType;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
/*eslint-disable no-console*/
|
||||||
|
|
||||||
var yaml = require('../lib/js-yaml');
|
var yaml = require('../lib/js-yaml');
|
||||||
var object = require('./dumper.json');
|
var object = require('./dumper.json');
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
/*eslint-disable no-console*/
|
||||||
|
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
|
|
||||||
|
|
||||||
function isNothing(subject) {
|
function isNothing(subject) {
|
||||||
return (undefined === subject) || (null === subject);
|
return (typeof subject === 'undefined') || (null === subject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function isObject(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;
|
return sequence;
|
||||||
} else if (isNothing(sequence)) {
|
} else if (isNothing(sequence)) {
|
||||||
return [];
|
return [];
|
||||||
} else {
|
|
||||||
return [ sequence ];
|
|
||||||
}
|
}
|
||||||
|
return [ sequence ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
/*eslint-disable no-use-before-define*/
|
||||||
|
|
||||||
var common = require('./common');
|
var common = require('./common');
|
||||||
var YAMLException = require('./exception');
|
var YAMLException = require('./exception');
|
||||||
var DEFAULT_FULL_SCHEMA = require('./schema/default_full');
|
var DEFAULT_FULL_SCHEMA = require('./schema/default_full');
|
||||||
var DEFAULT_SAFE_SCHEMA = require('./schema/default_safe');
|
var DEFAULT_SAFE_SCHEMA = require('./schema/default_safe');
|
||||||
|
|
||||||
|
|
||||||
var _toString = Object.prototype.toString;
|
var _toString = Object.prototype.toString;
|
||||||
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||||
|
|
||||||
|
|
||||||
var CHAR_TAB = 0x09; /* Tab */
|
var CHAR_TAB = 0x09; /* Tab */
|
||||||
var CHAR_LINE_FEED = 0x0A; /* LF */
|
var CHAR_LINE_FEED = 0x0A; /* LF */
|
||||||
var CHAR_CARRIAGE_RETURN = 0x0D; /* CR */
|
var CHAR_CARRIAGE_RETURN = 0x0D; /* CR */
|
||||||
|
@ -35,7 +34,6 @@ var CHAR_LEFT_CURLY_BRACKET = 0x7B; /* { */
|
||||||
var CHAR_VERTICAL_LINE = 0x7C; /* | */
|
var CHAR_VERTICAL_LINE = 0x7C; /* | */
|
||||||
var CHAR_RIGHT_CURLY_BRACKET = 0x7D; /* } */
|
var CHAR_RIGHT_CURLY_BRACKET = 0x7D; /* } */
|
||||||
|
|
||||||
|
|
||||||
var ESCAPE_SEQUENCES = {};
|
var ESCAPE_SEQUENCES = {};
|
||||||
|
|
||||||
ESCAPE_SEQUENCES[0x00] = '\\0';
|
ESCAPE_SEQUENCES[0x00] = '\\0';
|
||||||
|
@ -54,13 +52,11 @@ ESCAPE_SEQUENCES[0xA0] = '\\_';
|
||||||
ESCAPE_SEQUENCES[0x2028] = '\\L';
|
ESCAPE_SEQUENCES[0x2028] = '\\L';
|
||||||
ESCAPE_SEQUENCES[0x2029] = '\\P';
|
ESCAPE_SEQUENCES[0x2029] = '\\P';
|
||||||
|
|
||||||
|
|
||||||
var DEPRECATED_BOOLEANS_SYNTAX = [
|
var DEPRECATED_BOOLEANS_SYNTAX = [
|
||||||
'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON',
|
'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON',
|
||||||
'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF'
|
'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
function compileStyleMap(schema, map) {
|
function compileStyleMap(schema, map) {
|
||||||
var result, keys, index, length, tag, style, type;
|
var result, keys, index, length, tag, style, type;
|
||||||
|
|
||||||
|
@ -91,7 +87,6 @@ function compileStyleMap(schema, map) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function encodeHex(character) {
|
function encodeHex(character) {
|
||||||
var string, handle, length;
|
var string, handle, length;
|
||||||
|
|
||||||
|
@ -113,13 +108,13 @@ function encodeHex(character) {
|
||||||
return '\\' + handle + common.repeat('0', length - string.length) + string;
|
return '\\' + handle + common.repeat('0', length - string.length) + string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function State(options) {
|
function State(options) {
|
||||||
this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
|
this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
|
||||||
this.indent = Math.max(1, (options['indent'] || 2));
|
this.indent = Math.max(1, (options['indent'] || 2));
|
||||||
this.skipInvalid = options['skipInvalid'] || false;
|
this.skipInvalid = options['skipInvalid'] || false;
|
||||||
this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']);
|
this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']);
|
||||||
this.styleMap = compileStyleMap(this.schema, options['styles'] || null);
|
this.styleMap = compileStyleMap(this.schema, options['styles'] || null);
|
||||||
|
this.sortKeys = options['sortKeys'] || false;
|
||||||
|
|
||||||
this.implicitTypes = this.schema.compiledImplicit;
|
this.implicitTypes = this.schema.compiledImplicit;
|
||||||
this.explicitTypes = this.schema.compiledExplicit;
|
this.explicitTypes = this.schema.compiledExplicit;
|
||||||
|
@ -131,6 +126,31 @@ function State(options) {
|
||||||
this.usedDuplicates = null;
|
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) {
|
function generateNextLine(state, level) {
|
||||||
return '\n' + common.repeat(' ', state.indent * level);
|
return '\n' + common.repeat(' ', state.indent * level);
|
||||||
|
@ -150,81 +170,339 @@ function testImplicitResolving(state, str) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function writeScalar(state, object) {
|
function StringBuilder(source) {
|
||||||
var isQuoted, checkpoint, position, length, character, first;
|
this.source = source;
|
||||||
|
this.result = '';
|
||||||
|
this.checkpoint = 0;
|
||||||
|
}
|
||||||
|
|
||||||
state.dump = '';
|
StringBuilder.prototype.takeUpTo = function (position) {
|
||||||
isQuoted = false;
|
var er;
|
||||||
checkpoint = 0;
|
|
||||||
first = object.charCodeAt(0) || 0;
|
|
||||||
|
|
||||||
if (-1 !== DEPRECATED_BOOLEANS_SYNTAX.indexOf(object)) {
|
if (position < this.checkpoint) {
|
||||||
// Ensure compatibility with YAML 1.0/1.1 loaders.
|
er = new Error('position should be > checkpoint');
|
||||||
isQuoted = true;
|
er.position = position;
|
||||||
} else if (0 === object.length) {
|
er.checkpoint = this.checkpoint;
|
||||||
// Quote empty string
|
throw er;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (position = 0, length = object.length; position < length; position += 1) {
|
this.result += this.source.slice(this.checkpoint, position);
|
||||||
character = object.charCodeAt(position);
|
this.checkpoint = position;
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
if (!isQuoted) {
|
StringBuilder.prototype.escapeChar = function () {
|
||||||
if (CHAR_TAB === character ||
|
var character, esc;
|
||||||
CHAR_LINE_FEED === character ||
|
|
||||||
CHAR_CARRIAGE_RETURN === character ||
|
character = this.source.charCodeAt(this.checkpoint);
|
||||||
CHAR_COMMA === character ||
|
esc = ESCAPE_SEQUENCES[character] || encodeHex(character);
|
||||||
CHAR_LEFT_SQUARE_BRACKET === character ||
|
this.result += esc;
|
||||||
CHAR_RIGHT_SQUARE_BRACKET === character ||
|
this.checkpoint += 1;
|
||||||
CHAR_LEFT_CURLY_BRACKET === character ||
|
|
||||||
CHAR_RIGHT_CURLY_BRACKET === character ||
|
return this;
|
||||||
CHAR_SHARP === character ||
|
};
|
||||||
CHAR_AMPERSAND === character ||
|
|
||||||
CHAR_ASTERISK === character ||
|
StringBuilder.prototype.finish = function () {
|
||||||
CHAR_EXCLAMATION === character ||
|
if (this.source.length > this.checkpoint) {
|
||||||
CHAR_VERTICAL_LINE === character ||
|
this.takeUpTo(this.source.length);
|
||||||
CHAR_GREATER_THAN === character ||
|
}
|
||||||
CHAR_SINGLE_QUOTE === character ||
|
};
|
||||||
CHAR_DOUBLE_QUOTE === character ||
|
|
||||||
CHAR_PERCENT === character ||
|
function writeScalar(state, object, level) {
|
||||||
CHAR_COMMERCIAL_AT === character ||
|
var simple, first, spaceWrap, folded, literal, single, double,
|
||||||
CHAR_COLON === character ||
|
sawLineFeed, linePosition, longestLine, indent, max, character,
|
||||||
CHAR_GRAVE_ACCENT === character) {
|
position, escapeSeq, hexEsc, previous, lineLength, modifier,
|
||||||
isQuoted = true;
|
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] ||
|
if (single && character === CHAR_SINGLE_QUOTE) {
|
||||||
!((0x00020 <= character && character <= 0x00007E) ||
|
single = false;
|
||||||
(0x00085 === character) ||
|
}
|
||||||
(0x000A0 <= character && character <= 0x00D7FF) ||
|
|
||||||
(0x0E000 <= character && character <= 0x00FFFD) ||
|
escapeSeq = ESCAPE_SEQUENCES[character];
|
||||||
(0x10000 <= character && character <= 0x10FFFF))) {
|
hexEsc = needsHexEscape(character);
|
||||||
state.dump += object.slice(checkpoint, position);
|
|
||||||
state.dump += ESCAPE_SEQUENCES[character] || encodeHex(character);
|
if (!escapeSeq && !hexEsc) {
|
||||||
checkpoint = position + 1;
|
continue;
|
||||||
isQuoted = true;
|
}
|
||||||
|
|
||||||
|
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) {
|
if (literal && longestLine < max) {
|
||||||
state.dump += object.slice(checkpoint, position);
|
folded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isQuoted && testImplicitResolving(state, state.dump)) {
|
// If it's literally one line, then don't bother with the literal.
|
||||||
isQuoted = true;
|
// We may still want to do a fold, though, if it's a super long line.
|
||||||
|
if (!sawLineFeed) {
|
||||||
|
literal = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isQuoted) {
|
if (simple) {
|
||||||
state.dump = '"' + state.dump + '"';
|
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) {
|
function writeFlowSequence(state, level, object) {
|
||||||
|
@ -322,6 +600,18 @@ function writeBlockMapping(state, level, object, compact) {
|
||||||
explicitPair,
|
explicitPair,
|
||||||
pairBuffer;
|
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) {
|
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
||||||
pairBuffer = '';
|
pairBuffer = '';
|
||||||
|
|
||||||
|
@ -470,11 +760,12 @@ function writeNode(state, level, object, block, compact) {
|
||||||
}
|
}
|
||||||
} else if ('[object String]' === type) {
|
} else if ('[object String]' === type) {
|
||||||
if ('?' !== state.tag) {
|
if ('?' !== state.tag) {
|
||||||
writeScalar(state, state.dump);
|
writeScalar(state, state.dump, level);
|
||||||
}
|
}
|
||||||
} else if (state.skipInvalid) {
|
|
||||||
return false;
|
|
||||||
} else {
|
} else {
|
||||||
|
if (state.skipInvalid) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
throw new YAMLException('unacceptable kind of an object to dump ' + type);
|
throw new YAMLException('unacceptable kind of an object to dump ' + type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -514,8 +805,8 @@ function inspectNode(object, objects, duplicatesIndexes) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
objects.push(object);
|
objects.push(object);
|
||||||
|
|
||||||
if(Array.isArray(object)) {
|
if (Array.isArray(object)) {
|
||||||
for (index = 0, length = object.length; index < length; index += 1) {
|
for (index = 0, length = object.length; index < length; index += 1) {
|
||||||
inspectNode(object[index], objects, duplicatesIndexes);
|
inspectNode(object[index], objects, duplicatesIndexes);
|
||||||
}
|
}
|
||||||
|
@ -539,16 +830,13 @@ function dump(input, options) {
|
||||||
|
|
||||||
if (writeNode(state, 0, input, true, true)) {
|
if (writeNode(state, 0, input, true, true)) {
|
||||||
return state.dump + '\n';
|
return state.dump + '\n';
|
||||||
} else {
|
|
||||||
return '';
|
|
||||||
}
|
}
|
||||||
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function safeDump(input, options) {
|
function safeDump(input, options) {
|
||||||
return dump(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
|
return dump(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
module.exports.dump = dump;
|
module.exports.dump = dump;
|
||||||
module.exports.safeDump = safeDump;
|
module.exports.safeDump = safeDump;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
/*eslint-disable max-len,no-use-before-define*/
|
||||||
|
|
||||||
var common = require('./common');
|
var common = require('./common');
|
||||||
var YAMLException = require('./exception');
|
var YAMLException = require('./exception');
|
||||||
|
@ -22,7 +23,7 @@ var CHOMPING_STRIP = 2;
|
||||||
var CHOMPING_KEEP = 3;
|
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_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
|
||||||
var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
|
var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
|
||||||
var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
|
var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
|
||||||
|
@ -59,7 +60,9 @@ function fromHexCode(c) {
|
||||||
return c - 0x30;
|
return c - 0x30;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*eslint-disable no-bitwise*/
|
||||||
lc = c | 0x20;
|
lc = c | 0x20;
|
||||||
|
|
||||||
if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) {
|
if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) {
|
||||||
return lc - 0x61 + 10;
|
return lc - 0x61 + 10;
|
||||||
}
|
}
|
||||||
|
@ -83,7 +86,7 @@ function fromDecimalCode(c) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function simpleEscapeSequence(c) {
|
function simpleEscapeSequence(c) {
|
||||||
return (c === 0x30/* 0 */) ? '\x00' :
|
return (c === 0x30/* 0 */) ? '\x00' :
|
||||||
(c === 0x61/* a */) ? '\x07' :
|
(c === 0x61/* a */) ? '\x07' :
|
||||||
(c === 0x62/* b */) ? '\x08' :
|
(c === 0x62/* b */) ? '\x08' :
|
||||||
(c === 0x74/* t */) ? '\x09' :
|
(c === 0x74/* t */) ? '\x09' :
|
||||||
|
@ -106,12 +109,11 @@ function simpleEscapeSequence(c) {
|
||||||
function charFromCodepoint(c) {
|
function charFromCodepoint(c) {
|
||||||
if (c <= 0xFFFF) {
|
if (c <= 0xFFFF) {
|
||||||
return String.fromCharCode(c);
|
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
|
var simpleEscapeCheck = new Array(256); // integer, for fast access
|
||||||
|
@ -177,7 +179,7 @@ function throwWarning(state, message) {
|
||||||
|
|
||||||
var directiveHandlers = {
|
var directiveHandlers = {
|
||||||
|
|
||||||
'YAML': function handleYamlDirective(state, name, args) {
|
YAML: function handleYamlDirective(state, name, args) {
|
||||||
|
|
||||||
var match, major, minor;
|
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;
|
var handle, prefix;
|
||||||
|
|
||||||
|
@ -370,7 +372,7 @@ function testDocumentSeparator(state) {
|
||||||
// in parent on each call, for efficiency. No needs to test here again.
|
// in parent on each call, for efficiency. No needs to test here again.
|
||||||
if ((0x2D/* - */ === ch || 0x2E/* . */ === ch) &&
|
if ((0x2D/* - */ === ch || 0x2E/* . */ === ch) &&
|
||||||
state.input.charCodeAt(_position + 1) === ch &&
|
state.input.charCodeAt(_position + 1) === ch &&
|
||||||
state.input.charCodeAt(_position+ 2) === ch) {
|
state.input.charCodeAt(_position + 2) === ch) {
|
||||||
|
|
||||||
_position += 3;
|
_position += 3;
|
||||||
|
|
||||||
|
@ -440,7 +442,7 @@ function readPlainScalar(state, nodeIndent, withinFlowCollection) {
|
||||||
|
|
||||||
while (0 !== ch) {
|
while (0 !== ch) {
|
||||||
if (0x3A/* : */ === ch) {
|
if (0x3A/* : */ === ch) {
|
||||||
following = state.input.charCodeAt(state.position+1);
|
following = state.input.charCodeAt(state.position + 1);
|
||||||
|
|
||||||
if (is_WS_OR_EOL(following) ||
|
if (is_WS_OR_EOL(following) ||
|
||||||
withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
||||||
|
@ -495,11 +497,11 @@ function readPlainScalar(state, nodeIndent, withinFlowCollection) {
|
||||||
|
|
||||||
if (state.result) {
|
if (state.result) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
state.kind = _kind;
|
|
||||||
state.result = _result;
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
state.kind = _kind;
|
||||||
|
state.result = _result;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function readSingleQuotedScalar(state, nodeIndent) {
|
function readSingleQuotedScalar(state, nodeIndent) {
|
||||||
|
@ -578,7 +580,7 @@ function readDoubleQuotedScalar(state, nodeIndent) {
|
||||||
if (is_EOL(ch)) {
|
if (is_EOL(ch)) {
|
||||||
skipSeparationSpace(state, false, nodeIndent);
|
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]) {
|
} else if (ch < 256 && simpleEscapeCheck[ch]) {
|
||||||
state.result += simpleEscapeMap[ch];
|
state.result += simpleEscapeMap[ch];
|
||||||
state.position++;
|
state.position++;
|
||||||
|
@ -644,11 +646,11 @@ function readFlowCollection(state, nodeIndent) {
|
||||||
ch = state.input.charCodeAt(state.position);
|
ch = state.input.charCodeAt(state.position);
|
||||||
|
|
||||||
if (ch === 0x5B/* [ */) {
|
if (ch === 0x5B/* [ */) {
|
||||||
terminator = 0x5D/* ] */;
|
terminator = 0x5D;/* ] */
|
||||||
isMapping = false;
|
isMapping = false;
|
||||||
_result = [];
|
_result = [];
|
||||||
} else if (ch === 0x7B/* { */) {
|
} else if (ch === 0x7B/* { */) {
|
||||||
terminator = 0x7D/* } */;
|
terminator = 0x7D;/* } */
|
||||||
isMapping = true;
|
isMapping = true;
|
||||||
_result = {};
|
_result = {};
|
||||||
} else {
|
} else {
|
||||||
|
@ -850,24 +852,20 @@ function readBlockScalar(state, nodeIndent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Literal style: just add exact number of line breaks between content lines.
|
// 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 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.
|
// In case of the first content line - count only empty lines.
|
||||||
} else {
|
|
||||||
state.result += common.repeat('\n', emptyLines);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
detectedIndent = true;
|
detectedIndent = true;
|
||||||
emptyLines = 0;
|
emptyLines = 0;
|
||||||
captureStart = state.position;
|
captureStart = state.position;
|
||||||
|
|
||||||
while (!is_EOL(ch) && (0 !== ch))
|
while (!is_EOL(ch) && (0 !== ch)) {
|
||||||
{ ch = state.input.charCodeAt(++state.position); }
|
ch = state.input.charCodeAt(++state.position);
|
||||||
|
}
|
||||||
|
|
||||||
captureSegment(state, captureStart, state.position, false);
|
captureSegment(state, captureStart, state.position, false);
|
||||||
}
|
}
|
||||||
|
@ -933,9 +931,8 @@ function readBlockSequence(state, nodeIndent) {
|
||||||
state.kind = 'sequence';
|
state.kind = 'sequence';
|
||||||
state.result = _result;
|
state.result = _result;
|
||||||
return true;
|
return true;
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function readBlockMapping(state, nodeIndent, flowIndent) {
|
function readBlockMapping(state, nodeIndent, flowIndent) {
|
||||||
|
@ -1515,10 +1512,18 @@ function loadDocuments(input, options) {
|
||||||
input = String(input);
|
input = String(input);
|
||||||
options = options || {};
|
options = options || {};
|
||||||
|
|
||||||
if (0 !== input.length &&
|
if (input.length !== 0) {
|
||||||
0x0A/* LF */ !== input.charCodeAt(input.length - 1) &&
|
|
||||||
0x0D/* CR */ !== input.charCodeAt(input.length - 1)) {
|
// Add tailing `\n` if not exists
|
||||||
input += '\n';
|
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);
|
var state = new State(input, options);
|
||||||
|
@ -1556,12 +1561,12 @@ function load(input, options) {
|
||||||
var documents = loadDocuments(input, options), index, length;
|
var documents = loadDocuments(input, options), index, length;
|
||||||
|
|
||||||
if (0 === documents.length) {
|
if (0 === documents.length) {
|
||||||
|
/*eslint-disable no-undefined*/
|
||||||
return undefined;
|
return undefined;
|
||||||
} else if (1 === documents.length) {
|
} else if (1 === documents.length) {
|
||||||
return documents[0];
|
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';
|
'use strict';
|
||||||
|
|
||||||
|
/*eslint-disable max-len*/
|
||||||
|
|
||||||
var common = require('./common');
|
var common = require('./common');
|
||||||
var YAMLException = require('./exception');
|
var YAMLException = require('./exception');
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
/*eslint-disable no-bitwise*/
|
||||||
|
|
||||||
// A trick for browserified version.
|
// A trick for browserified version.
|
||||||
// Since we make browserifier to ignore `buffer` module, NodeBuffer will be undefined
|
// 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;
|
var code, idx, bitlen = 0, len = 0, max = data.length, map = BASE64_MAP;
|
||||||
|
|
||||||
// Convert one by one.
|
// Convert one by one.
|
||||||
for (idx = 0; idx < max; idx ++) {
|
for (idx = 0; idx < max; idx++) {
|
||||||
code = map.indexOf(data.charAt(idx));
|
code = map.indexOf(data.charAt(idx));
|
||||||
|
|
||||||
// Skip CR/LF
|
// Skip CR/LF
|
||||||
|
@ -57,7 +58,7 @@ function constructYamlBinary(data) {
|
||||||
|
|
||||||
// Dump tail
|
// Dump tail
|
||||||
|
|
||||||
tailbits = (max % 4)*6;
|
tailbits = (max % 4) * 6;
|
||||||
|
|
||||||
if (tailbits === 0) {
|
if (tailbits === 0) {
|
||||||
result.push((bits >> 16) & 0xFF);
|
result.push((bits >> 16) & 0xFF);
|
||||||
|
|
|
@ -55,9 +55,8 @@ function constructYamlFloat(data) {
|
||||||
|
|
||||||
return sign * value;
|
return sign * value;
|
||||||
|
|
||||||
} else {
|
|
||||||
return sign * parseFloat(value, 10);
|
|
||||||
}
|
}
|
||||||
|
return sign * parseFloat(value, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
function representYamlFloat(object, style) {
|
function representYamlFloat(object, style) {
|
||||||
|
@ -90,9 +89,8 @@ function representYamlFloat(object, style) {
|
||||||
}
|
}
|
||||||
} else if (common.isNegativeZero(object)) {
|
} else if (common.isNegativeZero(object)) {
|
||||||
return '-0.0';
|
return '-0.0';
|
||||||
} else {
|
|
||||||
return object.toString(10);
|
|
||||||
}
|
}
|
||||||
|
return object.toString(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isFloat(object) {
|
function isFloat(object) {
|
||||||
|
|
|
@ -38,7 +38,7 @@ function resolveYamlInteger(data) {
|
||||||
|
|
||||||
if (ch === '0') {
|
if (ch === '0') {
|
||||||
// 0
|
// 0
|
||||||
if (index+1 === max) { return true; }
|
if (index + 1 === max) { return true; }
|
||||||
ch = data[++index];
|
ch = data[++index];
|
||||||
|
|
||||||
// base 2, base 8, base 16
|
// base 2, base 8, base 16
|
||||||
|
|
|
@ -65,7 +65,8 @@ function constructJavascriptFunction(data) {
|
||||||
|
|
||||||
// Esprima's ranges include the first '{' and the last '}' characters on
|
// Esprima's ranges include the first '{' and the last '}' characters on
|
||||||
// function expressions. So cut them out.
|
// 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*/) {
|
function representJavascriptFunction(object /*, style*/) {
|
||||||
|
|
|
@ -7,6 +7,7 @@ function resolveJavascriptUndefined() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function constructJavascriptUndefined() {
|
function constructJavascriptUndefined() {
|
||||||
|
/*eslint-disable no-undefined*/
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue