govuk_publishing_components 16.29.0 → 17.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/govuk_publishing_components/components/cookie-banner.js +46 -23
- data/app/assets/javascripts/govuk_publishing_components/components/feedback.js +8 -2
- data/app/assets/javascripts/govuk_publishing_components/lib/cookie-functions.js +101 -21
- data/app/assets/javascripts/govuk_publishing_components/lib/govspeak/youtube-link-enhancement.js +9 -2
- data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +0 -1
- data/app/assets/stylesheets/govuk_publishing_components/components/_button.scss +4 -6
- data/app/assets/stylesheets/govuk_publishing_components/components/_cookie-banner.scss +36 -5
- data/app/assets/stylesheets/govuk_publishing_components/components/_heading.scss +14 -14
- data/app/assets/stylesheets/govuk_publishing_components/components/_highlight-boxes.scss +23 -23
- data/app/assets/stylesheets/govuk_publishing_components/components/_inverse-header.scss +8 -8
- data/app/assets/stylesheets/govuk_publishing_components/components/_lead-paragraph.scss +2 -2
- data/app/assets/stylesheets/govuk_publishing_components/components/_metadata.scss +8 -8
- data/app/assets/stylesheets/govuk_publishing_components/components/_organisation-logo.scss +10 -10
- data/app/assets/stylesheets/govuk_publishing_components/components/_previous-and-next-navigation.scss +11 -14
- data/app/assets/stylesheets/govuk_publishing_components/components/_related-navigation.scss +14 -14
- data/app/assets/stylesheets/govuk_publishing_components/components/_share-links.scss +8 -8
- data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav-header.scss +7 -7
- data/app/assets/stylesheets/govuk_publishing_components/components/_step-by-step-nav-related.scss +20 -16
- data/app/assets/stylesheets/govuk_publishing_components/components/_subscription-links.scss +4 -4
- data/app/assets/stylesheets/govuk_publishing_components/components/_success-alert.scss +5 -5
- data/app/assets/stylesheets/govuk_publishing_components/components/_taxonomy-list.scss +5 -5
- data/app/assets/stylesheets/govuk_publishing_components/components/_title.scss +8 -8
- data/app/assets/stylesheets/govuk_publishing_components/components/print/_step-by-step-nav-header.scss +1 -1
- data/app/views/govuk_publishing_components/components/_cookie_banner.html.erb +33 -25
- data/app/views/govuk_publishing_components/components/_error_summary.html.erb +4 -2
- data/app/views/govuk_publishing_components/components/_notice.html.erb +4 -1
- data/app/views/govuk_publishing_components/components/docs/cookie_banner.yml +2 -0
- data/app/views/govuk_publishing_components/components/docs/error_summary.yml +6 -0
- data/app/views/govuk_publishing_components/components/docs/notice.yml +6 -0
- data/app/views/govuk_publishing_components/components/docs/success_alert.yml +1 -1
- data/lib/govuk_publishing_components/presenters/cookie_banner_helper.rb +0 -4
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/node_modules/accessible-autocomplete/dist/accessible-autocomplete.min.js +1 -1
- data/node_modules/accessible-autocomplete/dist/accessible-autocomplete.min.js.map +1 -1
- data/node_modules/accessible-autocomplete/dist/lib/accessible-autocomplete.preact.min.js +1 -1
- data/node_modules/accessible-autocomplete/dist/lib/accessible-autocomplete.preact.min.js.map +1 -1
- data/node_modules/accessible-autocomplete/dist/lib/accessible-autocomplete.react.min.js +1 -1
- data/node_modules/accessible-autocomplete/dist/lib/accessible-autocomplete.react.min.js.map +1 -1
- data/node_modules/accessible-autocomplete/package.json +3 -3
- data/node_modules/accessible-autocomplete/src/autocomplete.js +4 -2
- data/node_modules/accessible-autocomplete/src/wrapper.js +5 -1
- data/node_modules/d/CHANGELOG.md +9 -0
- data/node_modules/d/CHANGES +4 -0
- data/node_modules/d/LICENSE +12 -16
- data/node_modules/d/README.md +49 -19
- data/node_modules/d/auto-bind.js +11 -10
- data/node_modules/d/index.js +23 -24
- data/node_modules/d/lazy.js +21 -23
- data/node_modules/d/package.json +63 -16
- data/node_modules/d/test/auto-bind.js +6 -7
- data/node_modules/d/test/index.js +78 -51
- data/node_modules/d/test/lazy.js +65 -50
- data/node_modules/es6-weak-map/CHANGELOG.md +5 -0
- data/node_modules/es6-weak-map/LICENSE +12 -16
- data/node_modules/es6-weak-map/README.md +34 -19
- data/node_modules/es6-weak-map/implement.js +9 -5
- data/node_modules/es6-weak-map/index.js +2 -2
- data/node_modules/es6-weak-map/is-implemented.js +10 -9
- data/node_modules/es6-weak-map/is-native-implemented.js +3 -3
- data/node_modules/es6-weak-map/is-weak-map.js +8 -8
- data/node_modules/es6-weak-map/package.json +30 -19
- data/node_modules/es6-weak-map/polyfill.js +31 -32
- data/node_modules/es6-weak-map/test/implement.js +4 -2
- data/node_modules/es6-weak-map/test/index.js +4 -3
- data/node_modules/es6-weak-map/test/is-implemented.js +9 -8
- data/node_modules/es6-weak-map/test/is-native-implemented.js +4 -2
- data/node_modules/es6-weak-map/test/is-weak-map.js +4 -4
- data/node_modules/es6-weak-map/test/polyfill.js +13 -13
- data/node_modules/es6-weak-map/test/valid-weak-map.js +22 -9
- data/node_modules/es6-weak-map/valid-weak-map.js +5 -5
- data/node_modules/resolve/lib/async.js +1 -1
- data/node_modules/resolve/lib/node-modules-paths.js +1 -1
- data/node_modules/resolve/lib/sync.js +0 -2
- data/node_modules/resolve/package.json +13 -13
- data/node_modules/resolve/test/node-modules-paths.js +0 -22
- data/node_modules/resolve/test/resolver.js +11 -0
- data/node_modules/resolve/test/resolver_sync.js +11 -0
- data/node_modules/standard/node_modules/ms/index.js +2 -2
- data/node_modules/standard/node_modules/ms/package.json +205 -16
- data/node_modules/standard/node_modules/ms/readme.md +1 -1
- data/node_modules/type/CHANGELOG.md +62 -0
- data/node_modules/type/README.md +743 -0
- data/node_modules/type/array-length/coerce.js +10 -0
- data/node_modules/type/array-length/ensure.js +10 -0
- data/node_modules/type/array-like/ensure.js +9 -0
- data/node_modules/type/array-like/is.js +21 -0
- data/node_modules/type/array/ensure.js +9 -0
- data/node_modules/type/array/is.js +27 -0
- data/node_modules/type/date/ensure.js +9 -0
- data/node_modules/type/date/is.js +26 -0
- data/node_modules/type/error/ensure.js +9 -0
- data/node_modules/type/error/is.js +24 -0
- data/node_modules/type/finite/coerce.js +8 -0
- data/node_modules/type/finite/ensure.js +10 -0
- data/node_modules/type/function/ensure.js +9 -0
- data/node_modules/type/function/is.js +19 -0
- data/node_modules/type/integer/coerce.js +11 -0
- data/node_modules/type/integer/ensure.js +10 -0
- data/node_modules/type/iterable/ensure.js +9 -0
- data/node_modules/type/iterable/is.js +20 -0
- data/node_modules/type/lib/is-to-string-tag-supported.js +3 -0
- data/node_modules/type/lib/resolve-exception.js +21 -0
- data/node_modules/type/lib/safe-to-string.js +10 -0
- data/node_modules/type/lib/to-short-string.js +29 -0
- data/node_modules/type/natural-number/coerce.js +10 -0
- data/node_modules/type/natural-number/ensure.js +10 -0
- data/node_modules/type/number/coerce.js +14 -0
- data/node_modules/type/number/ensure.js +10 -0
- data/node_modules/type/object/ensure.js +9 -0
- data/node_modules/type/object/is.js +11 -0
- data/node_modules/type/package.json +159 -0
- data/node_modules/type/plain-function/ensure.js +9 -0
- data/node_modules/type/plain-function/is.js +11 -0
- data/node_modules/type/plain-object/ensure.js +9 -0
- data/node_modules/type/plain-object/is.js +28 -0
- data/node_modules/type/promise/ensure.js +9 -0
- data/node_modules/type/promise/is.js +27 -0
- data/node_modules/type/prototype/is.js +13 -0
- data/node_modules/type/reg-exp/ensure.js +9 -0
- data/node_modules/type/reg-exp/is.js +37 -0
- data/node_modules/type/safe-integer/coerce.js +13 -0
- data/node_modules/type/safe-integer/ensure.js +10 -0
- data/node_modules/type/string/coerce.js +23 -0
- data/node_modules/type/string/ensure.js +10 -0
- data/node_modules/type/test/_lib/arrow-function-if-supported.js +4 -0
- data/node_modules/type/test/_lib/class-if-supported.js +4 -0
- data/node_modules/type/test/array-length/coerce.js +47 -0
- data/node_modules/type/test/array-length/ensure.js +19 -0
- data/node_modules/type/test/array-like/ensure.js +24 -0
- data/node_modules/type/test/array-like/is.js +47 -0
- data/node_modules/type/test/array/ensure.js +20 -0
- data/node_modules/type/test/array/is.js +41 -0
- data/node_modules/type/test/date/ensure.js +20 -0
- data/node_modules/type/test/date/is.js +46 -0
- data/node_modules/type/test/error/ensure.js +20 -0
- data/node_modules/type/test/error/is.js +42 -0
- data/node_modules/type/test/finite/coerce.js +40 -0
- data/node_modules/type/test/finite/ensure.js +17 -0
- data/node_modules/type/test/function/ensure.js +20 -0
- data/node_modules/type/test/function/is.js +46 -0
- data/node_modules/type/test/integer/coerce.js +49 -0
- data/node_modules/type/test/integer/ensure.js +17 -0
- data/node_modules/type/test/iterable/ensure.js +24 -0
- data/node_modules/type/test/iterable/is.js +50 -0
- data/node_modules/type/test/lib/is-to-string-tag-supported.js +10 -0
- data/node_modules/type/test/lib/resolve-exception.js +39 -0
- data/node_modules/type/test/lib/safe-to-string.js +32 -0
- data/node_modules/type/test/lib/to-short-string.js +41 -0
- data/node_modules/type/test/natural-number/coerce.js +47 -0
- data/node_modules/type/test/natural-number/ensure.js +19 -0
- data/node_modules/type/test/number/coerce.js +40 -0
- data/node_modules/type/test/number/ensure.js +17 -0
- data/node_modules/type/test/object/ensure.js +20 -0
- data/node_modules/type/test/object/is.js +30 -0
- data/node_modules/type/test/plain-function/ensure.js +20 -0
- data/node_modules/type/test/plain-function/is.js +56 -0
- data/node_modules/type/test/plain-object/ensure.js +20 -0
- data/node_modules/type/test/plain-object/is.js +47 -0
- data/node_modules/type/test/promise/ensure.js +20 -0
- data/node_modules/type/test/promise/is.js +39 -0
- data/node_modules/type/test/prototype/is.js +39 -0
- data/node_modules/type/test/reg-exp/ensure.js +20 -0
- data/node_modules/type/test/reg-exp/is.js +47 -0
- data/node_modules/type/test/safe-integer/coerce.js +49 -0
- data/node_modules/type/test/safe-integer/ensure.js +19 -0
- data/node_modules/type/test/string/coerce.js +36 -0
- data/node_modules/type/test/string/ensure.js +17 -0
- data/node_modules/type/test/thenable/ensure.js +20 -0
- data/node_modules/type/test/thenable/is.js +44 -0
- data/node_modules/type/test/time-value/coerce.js +47 -0
- data/node_modules/type/test/time-value/ensure.js +17 -0
- data/node_modules/type/test/value/ensure.js +20 -0
- data/node_modules/type/test/value/is.js +29 -0
- data/node_modules/type/thenable/ensure.js +9 -0
- data/node_modules/type/thenable/is.js +9 -0
- data/node_modules/type/time-value/coerce.js +12 -0
- data/node_modules/type/time-value/ensure.js +10 -0
- data/node_modules/type/value/ensure.js +9 -0
- data/node_modules/type/value/is.js +6 -0
- metadata +118 -21
- data/app/assets/stylesheets/govuk_publishing_components/components/_taxonomy-navigation.scss +0 -94
- data/node_modules/resolve/reaf +0 -0
- data/node_modules/resolve/test/shadowed_core.js +0 -38
- data/node_modules/resolve/test/shadowed_core/node_modules/util/index.js +0 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var resolveException = require("../lib/resolve-exception")
|
|
4
|
+
, coerce = require("./coerce");
|
|
5
|
+
|
|
6
|
+
module.exports = function (value/*, options*/) {
|
|
7
|
+
var coerced = coerce(value);
|
|
8
|
+
if (coerced !== null) return coerced;
|
|
9
|
+
return resolveException(value, "%v is not a valid array length", arguments[1]);
|
|
10
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var resolveException = require("../lib/resolve-exception")
|
|
4
|
+
, is = require("./is");
|
|
5
|
+
|
|
6
|
+
module.exports = function (value/*, options*/) {
|
|
7
|
+
if (is(value, arguments[1])) return value;
|
|
8
|
+
return resolveException(value, "%v is not an array like value", arguments[1]);
|
|
9
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var coerceToArrayLength = require("../array-length/coerce")
|
|
4
|
+
, isObject = require("../object/is");
|
|
5
|
+
|
|
6
|
+
module.exports = function (value/*, options*/) {
|
|
7
|
+
if (!isObject(value)) {
|
|
8
|
+
var options = arguments[1];
|
|
9
|
+
if (isObject(options) && options.allowString && typeof value === "string") return true;
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (typeof value === "function") return false;
|
|
14
|
+
|
|
15
|
+
var length;
|
|
16
|
+
try { length = value.length; }
|
|
17
|
+
catch (error) { return false; }
|
|
18
|
+
|
|
19
|
+
if (coerceToArrayLength(length) === null) return false;
|
|
20
|
+
return true;
|
|
21
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var resolveException = require("../lib/resolve-exception")
|
|
4
|
+
, is = require("./is");
|
|
5
|
+
|
|
6
|
+
module.exports = function (value/*, options*/) {
|
|
7
|
+
if (is(value)) return value;
|
|
8
|
+
return resolveException(value, "%v is not an array object", arguments[1]);
|
|
9
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var isPrototype = require("../prototype/is");
|
|
4
|
+
|
|
5
|
+
var isArray;
|
|
6
|
+
if (typeof Array.isArray === "function") {
|
|
7
|
+
isArray = Array.isArray;
|
|
8
|
+
} else {
|
|
9
|
+
var objectToString = Object.prototype.toString, objectTaggedString = objectToString.call([]);
|
|
10
|
+
isArray = function (value) { return objectToString.call(value) === objectTaggedString; };
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
module.exports = function (value) {
|
|
14
|
+
if (!isArray(value)) return false;
|
|
15
|
+
|
|
16
|
+
// Sanity check (reject objects which do not expose common Array interface)
|
|
17
|
+
if (!hasOwnProperty.call(value, "length")) return false;
|
|
18
|
+
try {
|
|
19
|
+
if (typeof value.length !== "number") return false;
|
|
20
|
+
if (typeof value.push !== "function") return false;
|
|
21
|
+
if (typeof value.splice !== "function") return false;
|
|
22
|
+
} catch (error) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return !isPrototype(value);
|
|
27
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var resolveException = require("../lib/resolve-exception")
|
|
4
|
+
, is = require("./is");
|
|
5
|
+
|
|
6
|
+
module.exports = function (value/*, options*/) {
|
|
7
|
+
if (is(value)) return value;
|
|
8
|
+
return resolveException(value, "%v is not a date object", arguments[1]);
|
|
9
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var isPrototype = require("../prototype/is");
|
|
4
|
+
|
|
5
|
+
var dateValueOf = Date.prototype.valueOf;
|
|
6
|
+
|
|
7
|
+
module.exports = function (value) {
|
|
8
|
+
if (!value) return false;
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
// Sanity check (reject objects which do not expose common Date interface)
|
|
12
|
+
if (typeof value.getFullYear !== "function") return false;
|
|
13
|
+
if (typeof value.getTimezoneOffset !== "function") return false;
|
|
14
|
+
if (typeof value.setFullYear !== "function") return false;
|
|
15
|
+
|
|
16
|
+
// Ensure its native Date object (has [[DateValue]] slot)
|
|
17
|
+
dateValueOf.call(value);
|
|
18
|
+
} catch (error) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Ensure it hosts valid date
|
|
23
|
+
if (isNaN(value)) return false;
|
|
24
|
+
|
|
25
|
+
return !isPrototype(value);
|
|
26
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var resolveException = require("../lib/resolve-exception")
|
|
4
|
+
, is = require("./is");
|
|
5
|
+
|
|
6
|
+
module.exports = function (value/*, options*/) {
|
|
7
|
+
if (is(value)) return value;
|
|
8
|
+
return resolveException(value, "%v is not an error object", arguments[1]);
|
|
9
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var isPrototype = require("../prototype/is");
|
|
4
|
+
|
|
5
|
+
var objectToString = Object.prototype.toString
|
|
6
|
+
, objectTaggedString = objectToString.call(new Error());
|
|
7
|
+
|
|
8
|
+
module.exports = function (value) {
|
|
9
|
+
if (!value) return false;
|
|
10
|
+
|
|
11
|
+
// Sanity check (reject objects which do not expose common Error interface)
|
|
12
|
+
try {
|
|
13
|
+
if (typeof value.message !== "string") return false;
|
|
14
|
+
} catch (error) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Ensure its native Error object (has [[ErrorData]] slot)
|
|
19
|
+
// Note: it's not 100% precise as string tag may be overriden
|
|
20
|
+
// and other objects can be hacked to expose it
|
|
21
|
+
if (objectToString.call(value) !== objectTaggedString) return false;
|
|
22
|
+
|
|
23
|
+
return !isPrototype(value);
|
|
24
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var resolveException = require("../lib/resolve-exception")
|
|
4
|
+
, coerce = require("./coerce");
|
|
5
|
+
|
|
6
|
+
module.exports = function (value/*, options*/) {
|
|
7
|
+
var coerced = coerce(value);
|
|
8
|
+
if (coerced !== null) return coerced;
|
|
9
|
+
return resolveException(value, "%v is not a finite number", arguments[1]);
|
|
10
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var isPrototype = require("../prototype/is");
|
|
4
|
+
|
|
5
|
+
module.exports = function (value) {
|
|
6
|
+
if (typeof value !== "function") return false;
|
|
7
|
+
|
|
8
|
+
if (!hasOwnProperty.call(value, "length")) return false;
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
if (typeof value.length !== "number") return false;
|
|
12
|
+
if (typeof value.call !== "function") return false;
|
|
13
|
+
if (typeof value.apply !== "function") return false;
|
|
14
|
+
} catch (error) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return !isPrototype(value);
|
|
19
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var coerceToFinite = require("../finite/coerce");
|
|
4
|
+
|
|
5
|
+
var abs = Math.abs, floor = Math.floor;
|
|
6
|
+
|
|
7
|
+
module.exports = function (value) {
|
|
8
|
+
value = coerceToFinite(value);
|
|
9
|
+
if (!value) return value;
|
|
10
|
+
return (value > 0 ? 1 : -1) * floor(abs(value));
|
|
11
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var resolveException = require("../lib/resolve-exception")
|
|
4
|
+
, coerce = require("./coerce");
|
|
5
|
+
|
|
6
|
+
module.exports = function (value/*, options*/) {
|
|
7
|
+
var coerced = coerce(value);
|
|
8
|
+
if (coerced !== null) return coerced;
|
|
9
|
+
return resolveException(value, "%v is not an integer", arguments[1]);
|
|
10
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var resolveException = require("../lib/resolve-exception")
|
|
4
|
+
, is = require("./is");
|
|
5
|
+
|
|
6
|
+
module.exports = function (value/*, options*/) {
|
|
7
|
+
if (is(value, arguments[1])) return value;
|
|
8
|
+
return resolveException(value, "%v is not an iterable value", arguments[1]);
|
|
9
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Polyfills friendly, therefore ES5 syntax
|
|
2
|
+
|
|
3
|
+
"use strict";
|
|
4
|
+
|
|
5
|
+
var isObject = require("../object/is");
|
|
6
|
+
|
|
7
|
+
var iteratorSymbol = Symbol.iterator;
|
|
8
|
+
|
|
9
|
+
if (!iteratorSymbol) {
|
|
10
|
+
throw new Error("Cannot initialize iterator/is due to Symbol.iterator not being implemented");
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
module.exports = function (value/*, options*/) {
|
|
14
|
+
if (!isObject(value)) {
|
|
15
|
+
var options = arguments[1];
|
|
16
|
+
if (!isObject(options) || !options.allowString || typeof value !== "string") return false;
|
|
17
|
+
}
|
|
18
|
+
try { return typeof value[iteratorSymbol] === "function"; }
|
|
19
|
+
catch (error) { return false; }
|
|
20
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var isValue = require("../value/is")
|
|
4
|
+
, isObject = require("../object/is")
|
|
5
|
+
, stringCoerce = require("../string/coerce")
|
|
6
|
+
, toShortString = require("./to-short-string");
|
|
7
|
+
|
|
8
|
+
var resolveMessage = function (message, value) {
|
|
9
|
+
return message.replace("%v", toShortString(value));
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
module.exports = function (value, defaultMessage, inputOptions) {
|
|
13
|
+
if (!isObject(inputOptions)) throw new TypeError(resolveMessage(defaultMessage, value));
|
|
14
|
+
if (!isValue(value)) {
|
|
15
|
+
if ("default" in inputOptions) return inputOptions["default"];
|
|
16
|
+
if (inputOptions.isOptional) return null;
|
|
17
|
+
}
|
|
18
|
+
var errorMessage = stringCoerce(inputOptions.errorMessage);
|
|
19
|
+
if (!isValue(errorMessage)) errorMessage = defaultMessage;
|
|
20
|
+
throw new TypeError(resolveMessage(errorMessage, value));
|
|
21
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var safeToString = require("./safe-to-string");
|
|
4
|
+
|
|
5
|
+
var reNewLine = /[\n\r\u2028\u2029]/g;
|
|
6
|
+
|
|
7
|
+
module.exports = function (value) {
|
|
8
|
+
var string = safeToString(value);
|
|
9
|
+
if (string === null) return "<Non-coercible to string value>";
|
|
10
|
+
// Trim if too long
|
|
11
|
+
if (string.length > 100) string = string.slice(0, 99) + "…";
|
|
12
|
+
// Replace eventual new lines
|
|
13
|
+
string = string.replace(reNewLine, function (char) {
|
|
14
|
+
switch (char) {
|
|
15
|
+
case "\n":
|
|
16
|
+
return "\\n";
|
|
17
|
+
case "\r":
|
|
18
|
+
return "\\r";
|
|
19
|
+
case "\u2028":
|
|
20
|
+
return "\\u2028";
|
|
21
|
+
case "\u2029":
|
|
22
|
+
return "\\u2029";
|
|
23
|
+
/* istanbul ignore next */
|
|
24
|
+
default:
|
|
25
|
+
throw new Error("Unexpected character");
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
return string;
|
|
29
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var resolveException = require("../lib/resolve-exception")
|
|
4
|
+
, coerce = require("./coerce");
|
|
5
|
+
|
|
6
|
+
module.exports = function (value/*, options*/) {
|
|
7
|
+
var coerced = coerce(value);
|
|
8
|
+
if (coerced !== null) return coerced;
|
|
9
|
+
return resolveException(value, "%v is not a natural number", arguments[1]);
|
|
10
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var isValue = require("../value/is");
|
|
4
|
+
|
|
5
|
+
module.exports = function (value) {
|
|
6
|
+
if (!isValue(value)) return null;
|
|
7
|
+
try {
|
|
8
|
+
value = +value; // Ensure implicit coercion
|
|
9
|
+
} catch (error) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
if (isNaN(value)) return null;
|
|
13
|
+
return value;
|
|
14
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var resolveException = require("../lib/resolve-exception")
|
|
4
|
+
, coerce = require("./coerce");
|
|
5
|
+
|
|
6
|
+
module.exports = function (value/*, options*/) {
|
|
7
|
+
var coerced = coerce(value);
|
|
8
|
+
if (coerced !== null) return coerced;
|
|
9
|
+
return resolveException(value, "%v is not a number", arguments[1]);
|
|
10
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var isValue = require("../value/is");
|
|
4
|
+
|
|
5
|
+
// prettier-ignore
|
|
6
|
+
var possibleTypes = { "object": true, "function": true, "undefined": true /* document.all */ };
|
|
7
|
+
|
|
8
|
+
module.exports = function (value) {
|
|
9
|
+
if (!isValue(value)) return false;
|
|
10
|
+
return hasOwnProperty.call(possibleTypes, typeof value);
|
|
11
|
+
};
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_args": [
|
|
3
|
+
[
|
|
4
|
+
{
|
|
5
|
+
"raw": "type@^1.0.1",
|
|
6
|
+
"scope": null,
|
|
7
|
+
"escapedName": "type",
|
|
8
|
+
"name": "type",
|
|
9
|
+
"rawSpec": "^1.0.1",
|
|
10
|
+
"spec": ">=1.0.1 <2.0.0",
|
|
11
|
+
"type": "range"
|
|
12
|
+
},
|
|
13
|
+
"/var/lib/jenkins/workspace/ublishing_components_master-N4FWJIUY4CIFHKGZOAAEVVXODRY3YBORQOPIBBXWX72VUPSGJRRQ/node_modules/d"
|
|
14
|
+
]
|
|
15
|
+
],
|
|
16
|
+
"_from": "type@>=1.0.1 <2.0.0",
|
|
17
|
+
"_hasShrinkwrap": false,
|
|
18
|
+
"_id": "type@1.0.1",
|
|
19
|
+
"_inCache": true,
|
|
20
|
+
"_location": "/type",
|
|
21
|
+
"_nodeVersion": "11.13.0",
|
|
22
|
+
"_npmOperationalInternal": {
|
|
23
|
+
"host": "s3://npm-registry-packages",
|
|
24
|
+
"tmp": "tmp/type_1.0.1_1554733326657_0.6015133915569804"
|
|
25
|
+
},
|
|
26
|
+
"_npmUser": {
|
|
27
|
+
"name": "medikoo",
|
|
28
|
+
"email": "medikoo+npm@medikoo.com"
|
|
29
|
+
},
|
|
30
|
+
"_npmVersion": "6.7.0",
|
|
31
|
+
"_phantomChildren": {},
|
|
32
|
+
"_requested": {
|
|
33
|
+
"raw": "type@^1.0.1",
|
|
34
|
+
"scope": null,
|
|
35
|
+
"escapedName": "type",
|
|
36
|
+
"name": "type",
|
|
37
|
+
"rawSpec": "^1.0.1",
|
|
38
|
+
"spec": ">=1.0.1 <2.0.0",
|
|
39
|
+
"type": "range"
|
|
40
|
+
},
|
|
41
|
+
"_requiredBy": [
|
|
42
|
+
"/d"
|
|
43
|
+
],
|
|
44
|
+
"_resolved": "https://registry.npmjs.org/type/-/type-1.0.1.tgz",
|
|
45
|
+
"_shasum": "084c9a17fcc9151a2cdb1459905c2e45e4bb7d61",
|
|
46
|
+
"_shrinkwrap": null,
|
|
47
|
+
"_spec": "type@^1.0.1",
|
|
48
|
+
"_where": "/var/lib/jenkins/workspace/ublishing_components_master-N4FWJIUY4CIFHKGZOAAEVVXODRY3YBORQOPIBBXWX72VUPSGJRRQ/node_modules/d",
|
|
49
|
+
"author": {
|
|
50
|
+
"name": "Mariusz Nowak",
|
|
51
|
+
"email": "medyk@medikoo.com",
|
|
52
|
+
"url": "https://www.medikoo.com/"
|
|
53
|
+
},
|
|
54
|
+
"bugs": {
|
|
55
|
+
"url": "https://github.com/medikoo/type/issues"
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {},
|
|
58
|
+
"description": "Runtime validation and processing of JavaScript types",
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"chai": "^4.2.0",
|
|
61
|
+
"eslint": "^5.15.3",
|
|
62
|
+
"eslint-config-medikoo-es3": "^2.1.0",
|
|
63
|
+
"git-list-updated": "^1.1.2",
|
|
64
|
+
"husky": "^1.3.1",
|
|
65
|
+
"lint-staged": "^8.1.5",
|
|
66
|
+
"mocha": "^6.0.2",
|
|
67
|
+
"nyc": "^13.3.0",
|
|
68
|
+
"prettier-elastic": "^1.16.4"
|
|
69
|
+
},
|
|
70
|
+
"directories": {},
|
|
71
|
+
"dist": {
|
|
72
|
+
"integrity": "sha512-MAM5dBMJCJNKs9E7JXo4CXRAansRfG0nlJxW7Wf6GZzSOvH31zClSaHdIMWLehe/EGMBkqeC55rrkaOr5Oo7Nw==",
|
|
73
|
+
"shasum": "084c9a17fcc9151a2cdb1459905c2e45e4bb7d61",
|
|
74
|
+
"tarball": "https://registry.npmjs.org/type/-/type-1.0.1.tgz",
|
|
75
|
+
"fileCount": 101,
|
|
76
|
+
"unpackedSize": 96534,
|
|
77
|
+
"npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcq1kPCRA9TVsSAnZWagAAVE8QAJJjMCA7+LIxgjYVhAwD\n85yQgnZ6fknasTdqYOo7qjYIntEgZ5smEKWzh9eofRv/pWEN/80+B4cOX6Hr\niZVJdvTH//Ahd9d6cNK34pVan5DbhUYX8SW8RLFgangaLAmzcCo+17C4TxWv\nHRi5vFbl8dQLHda28EOfMC2CWzxnp91flTxjGCDBGwhLIv8kAEI6z8lM+PnL\nP3Hg6GK2Q87aOHU287RvsZxpegn4pLDuRmfHYg/25tfDT5sdr2us481oGx6S\nb1o4B37AS3Kv65yShe55ymx4JvZd/EKLaWUfwBltKPaoOBO3/yuZA8HMbaDk\nRKPlCbiPOQndTsiwEzjgyKDZL8u+xIdtl3M8vSbPf5a3yZDZ970kDIoCmQe8\nFEDSTpiyKXMeroLbxGlN3LeIc1gE1a/HlAQmURlP4DxkH4WjjWPiKjBtcFwM\nhzXyiYyUX4O3DjdHfeDVU+G6y2OnQOLXKhT08ijZzCHaVEhSUAsVqfZroRM1\nSCZfUC03D0/DGDtPUhrsFTf4hdyr1OkS14DWJmF9ydSps5NGKdVGmXvcGIGJ\nuPTk8u7Cu9fTjJerG1hv5s7d9C9A2OU9/RV3e1s2hnVv/mhFeUGrY3GAvibH\nGtue/TeGFkkHJVrtHORQJO0dRaSP7hLjx0Eh3Sdp2Z8fPvKhfPRmW+PNgKhL\nrmu9\r\n=1gzz\r\n-----END PGP SIGNATURE-----\r\n"
|
|
78
|
+
},
|
|
79
|
+
"eslintConfig": {
|
|
80
|
+
"extends": "medikoo-es3",
|
|
81
|
+
"root": true,
|
|
82
|
+
"globals": {
|
|
83
|
+
"Map": true,
|
|
84
|
+
"Promise": true,
|
|
85
|
+
"Set": true,
|
|
86
|
+
"Symbol": true
|
|
87
|
+
},
|
|
88
|
+
"overrides": [
|
|
89
|
+
{
|
|
90
|
+
"files": "test/**/*.js",
|
|
91
|
+
"env": {
|
|
92
|
+
"mocha": true
|
|
93
|
+
},
|
|
94
|
+
"rules": {
|
|
95
|
+
"no-eval": "off",
|
|
96
|
+
"no-new-wrappers": "off"
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"files": [
|
|
101
|
+
"string/coerce.js",
|
|
102
|
+
"number/coerce.js"
|
|
103
|
+
],
|
|
104
|
+
"rules": {
|
|
105
|
+
"no-implicit-coercion": "off"
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"files": "plain-object/is.js",
|
|
110
|
+
"rules": {
|
|
111
|
+
"no-proto": "off"
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
},
|
|
116
|
+
"gitHead": "eb9e77ae26450e8d250db7f1f1b5e01f13011750",
|
|
117
|
+
"homepage": "https://github.com/medikoo/type#readme",
|
|
118
|
+
"husky": {
|
|
119
|
+
"hooks": {
|
|
120
|
+
"pre-commit": "lint-staged"
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
"keywords": [
|
|
124
|
+
"type",
|
|
125
|
+
"coercion"
|
|
126
|
+
],
|
|
127
|
+
"license": "ISC",
|
|
128
|
+
"lint-staged": {
|
|
129
|
+
"*.js": [
|
|
130
|
+
"eslint"
|
|
131
|
+
],
|
|
132
|
+
"*.{css,html,js,json,md,yaml,yml}": [
|
|
133
|
+
"prettier -c"
|
|
134
|
+
]
|
|
135
|
+
},
|
|
136
|
+
"maintainers": [
|
|
137
|
+
{
|
|
138
|
+
"name": "gozala",
|
|
139
|
+
"email": "rfobic@gmail.com"
|
|
140
|
+
}
|
|
141
|
+
],
|
|
142
|
+
"name": "type",
|
|
143
|
+
"optionalDependencies": {},
|
|
144
|
+
"readme": "ERROR: No README data found!",
|
|
145
|
+
"repository": {
|
|
146
|
+
"type": "git",
|
|
147
|
+
"url": "git+https://github.com/medikoo/type.git"
|
|
148
|
+
},
|
|
149
|
+
"scripts": {
|
|
150
|
+
"check-coverage": "npm run coverage && nyc check-coverage --statements 80 --function 80 --branches 80 --lines 80",
|
|
151
|
+
"coverage": "nyc --reporter=lcov --reporter=html --reporter=text-summary npm test",
|
|
152
|
+
"lint": "eslint --ignore-path=.gitignore .",
|
|
153
|
+
"lint-updated": "pipe-git-updated --ext=js -- eslint --ignore-pattern '!*'",
|
|
154
|
+
"prettier-check-updated": "pipe-git-updated --ext=css --ext=html --ext=js --ext=json --ext=md --ext=yaml --ext=yml -- prettier -c",
|
|
155
|
+
"prettify": "prettier --write --ignore-path .gitignore '**/*.{css,html,js,json,md,yaml,yml}'",
|
|
156
|
+
"test": "mocha --recursive"
|
|
157
|
+
},
|
|
158
|
+
"version": "1.0.1"
|
|
159
|
+
}
|