@stdlib/esm
Version:
ES module distribution for Stdlib, a standard library for JavaScript and Node.js.
3 lines • 2.34 kB
JavaScript
// This file is a part of stdlib. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0
import r from"./../utils/define-nonenumerable-read-only-property.js";import e from"./../assert/is-nonnegative-integer.js";import n from"./../assert/is-plain-object.js";import o from"./../assert/has-own-property.js";import t from"./../assert/contains.js";import i from"./../symbol/iterator.js";import a from"./../math/base/special/floor.js";import s from"./../math/base/special/ceil.js";import u from"./../math/base/special/round.js";import m from"./../assert/is-string.js";import d from"./../assert/is-date-object.js";var l=m.isPrimitive,p=e.isPrimitive,f=d;function g(r){return l(r)?(r=Date.parse(r))!=r?new TypeError("invalid argument. Unable to parse date string. Value: `"+r+"`."):r:p(r)?r:f(r)?r.getTime():new TypeError("invalid argument. Must provide either a Date object, a JavaScript timestamp (i.e., a nonnegative integer), or a date string. Value: `"+r+"`.")}var v=r,c=e.isPrimitive,h=n,w=o,j=t,b=i,y=a,T=s,E=u,D=g,V=100,P="floor",U=["floor","ceil","round"],x={floor:y,ceil:T,round:E};function z(r,e,n,o){var t,i,a,s,u,m,d,l,p,f;if((m=D(r))instanceof Error)throw m;if((d=D(e))instanceof Error)throw d;if(a={round:P},3===arguments.length)if(c(n))l=n;else{if(!h(n))throw new TypeError("invalid argument. Third argument must be either a nonnegative integer or an options object. Value: `"+n+"`.");if(l=V,w(n,"round")){if(!j(U,n.round))throw new TypeError("invalid option. Unrecognized rounding mode. Option: `"+n.round+"`.");a.round=n.round}}else if(arguments.length>3){if(!c(n))throw new TypeError("invalid argument. Third argument must be a nonnegative integer. Value: `"+n+"`.");if(l=n,!h(o))throw new TypeError("invalid argument. Fourth argument must be an object. Value: `"+o+"`.");if(w(o,"round")){if(!j(U,o.round))throw new TypeError("invalid option. Unrecognized rounding mode. Option: `"+o.round+"`.");a.round=o.round}}else l=V;return s=x[a.round],t=(d-m)/(p=l-1),f=-1,v(i={},"next",g),v(i,"return",y),b&&v(i,b,T),i;function g(){return f+=1,u||f>=l?{done:!0}:0===f?{value:new Date(m),done:!1}:f===p?{value:new Date(d),done:!1}:{value:new Date(s(m+f*t)),done:!1}}function y(r){return u=!0,arguments.length?{value:r,done:!0}:{done:!0}}function T(){return z(r,e,l,a)}}var O=z;export default O;
//# sourceMappingURL=datespace.js.map