New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

alga-js

Package Overview
Dependencies
Maintainers
1
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

alga-js - npm Package Compare versions

Comparing version 0.1.0-stone-6 to 0.1.0-stone-7

ts/number/spaceNumber.ts

5

lib/number/number.cjs.js

@@ -77,4 +77,9 @@ 'use strict';

var spaceBetween = function (numArg) {
return String(numArg).replace(/\d{4}(?=.)/g, '$& ');
};
exports.percentage = percentage;
exports.separator = separator;
exports.spaceBetween = spaceBetween;
exports.unit = unit;

6

lib/number/number.es.js

@@ -73,2 +73,6 @@ var separator = function (value, separator, float) {

export { percentage, separator, unit };
var spaceBetween = function (numArg) {
return String(numArg).replace(/\d{4}(?=.)/g, '$& ');
};
export { percentage, separator, spaceBetween, unit };

2

lib/number/number.js

@@ -1,1 +0,1 @@

var number=function(e){"use strict";return e.percentage=function(e,r,l){void 0===l&&(l=!1);var i=String(Math.round(100*(Number(e)/Number(r)-1)));return!0===l&&(i+="%"),i},e.separator=function(e,r,l){void 0===r&&(r=","),void 0===l&&(l=!1);var i="."===r?"de-DE":"en-US",u="."===r?0:1,o=String(new Intl.NumberFormat(i,{style:"currency",currency:"IDR"}).format(Number(e)));if(o=o.split(/\s/)[u],!0!==l){var n="."===r?",":".";o=o.split(n)[0].trim()}return o},e.unit=function(e,r,l){void 0===r&&(r=2),void 0===l&&(l="normal");var i=[{id:1,value:1,symbol:""},{id:2,value:1e3,symbol:"K"},{id:3,value:1e6,symbol:"M"},{id:4,value:1e9,symbol:"G"},{id:5,value:1e12,symbol:"T"},{id:6,value:1e15,symbol:"P"},{id:7,value:1e18,symbol:"E"},{id:8,value:1e21,symbol:"Z"},{id:9,value:1e24,symbol:"Y"}];"normal"!==l&&(i=i.map((function(e){return"decimal"===l?2===e.id&&(e.symbol="k"):"money"===l?4===e.id&&(e.symbol="B"):"binary"===l?1!==e.id&&(e.value=e.value+24*(e.id-1),e.symbol=e.symbol+"i"):"byte"===l&&1!==e.id&&(e.value=e.value+24*(e.id-1),e.symbol=e.symbol+"B"),e})));var u=i.slice().reverse().find((function(r){return Number(e)>=r.value}));return u?(Number(e)/u.value).toFixed(r).replace(/\.0+$|(\.[0-9]*[1-9])0+$/,"$1")+""+u.symbol:"0"},Object.defineProperty(e,"__esModule",{value:!0}),e}({});
var number=function(e){"use strict";return e.percentage=function(e,r,i){void 0===i&&(i=!1);var l=String(Math.round(100*(Number(e)/Number(r)-1)));return!0===i&&(l+="%"),l},e.separator=function(e,r,i){void 0===r&&(r=","),void 0===i&&(i=!1);var l="."===r?"de-DE":"en-US",u="."===r?0:1,n=String(new Intl.NumberFormat(l,{style:"currency",currency:"IDR"}).format(Number(e)));if(n=n.split(/\s/)[u],!0!==i){var o="."===r?",":".";n=n.split(o)[0].trim()}return n},e.spaceBetween=function(e){return String(e).replace(/\d{4}(?=.)/g,"$& ")},e.unit=function(e,r,i){void 0===r&&(r=2),void 0===i&&(i="normal");var l=[{id:1,value:1,symbol:""},{id:2,value:1e3,symbol:"K"},{id:3,value:1e6,symbol:"M"},{id:4,value:1e9,symbol:"G"},{id:5,value:1e12,symbol:"T"},{id:6,value:1e15,symbol:"P"},{id:7,value:1e18,symbol:"E"},{id:8,value:1e21,symbol:"Z"},{id:9,value:1e24,symbol:"Y"}];"normal"!==i&&(l=l.map((function(e){return"decimal"===i?2===e.id&&(e.symbol="k"):"money"===i?4===e.id&&(e.symbol="B"):"binary"===i?1!==e.id&&(e.value=e.value+24*(e.id-1),e.symbol=e.symbol+"i"):"byte"===i&&1!==e.id&&(e.value=e.value+24*(e.id-1),e.symbol=e.symbol+"B"),e})));var u=l.slice().reverse().find((function(r){return Number(e)>=r.value}));return u?(Number(e)/u.value).toFixed(r).replace(/\.0+$|(\.[0-9]*[1-9])0+$/,"$1")+""+u.symbol:"0"},Object.defineProperty(e,"__esModule",{value:!0}),e}({});

@@ -5,6 +5,7 @@ 'use strict';

var relative = function (dateValue, timeZone, locale, options, defaultValue) {
var relative = function (dateValue, timeZone, locale, options, type) {
if (timeZone === void 0) { timeZone = 'utc'; }
if (locale === void 0) { locale = 'en-US'; }
if (options === void 0) { options = {}; }
if (type === void 0) { type = 'long'; }
var nowDate = new Date();

@@ -16,3 +17,6 @@ var valDate = new Date(dateValue);

var seconds = Math.round((valDate.valueOf() - nowDate.valueOf()) / 1000);
var newTimeRelative = new Intl.RelativeTimeFormat(locale, options).format(Math.round(seconds), 'second');
var newTimeRelative = new Intl.RelativeTimeFormat(locale, options).format(seconds, 'second');
if (type === 'short') {
newTimeRelative = "".concat(Math.abs(Math.round(seconds)), "s");
}
var interval = seconds / 31536000;

@@ -22,2 +26,5 @@ if (Math.abs(interval) > 1) {

newTimeRelative = new Intl.RelativeTimeFormat(locale, options).format(newInterval, 'year');
if (type === 'short') {
newTimeRelative = "".concat(Math.abs(Math.round(newInterval)), "y");
}
}

@@ -29,2 +36,5 @@ else {

newTimeRelative = new Intl.RelativeTimeFormat(locale, options).format(newInterval, 'month');
if (type === 'short') {
newTimeRelative = "".concat(Math.abs(Math.round(newInterval)), "mo");
}
}

@@ -36,2 +46,5 @@ else {

newTimeRelative = new Intl.RelativeTimeFormat(locale, options).format(newInterval, 'day');
if (type === 'short') {
newTimeRelative = "".concat(Math.abs(Math.round(newInterval)), "d");
}
}

@@ -43,2 +56,5 @@ else {

newTimeRelative = new Intl.RelativeTimeFormat(locale, options).format(newInterval, 'hour');
if (type === 'short') {
newTimeRelative = "".concat(Math.abs(Math.round(newInterval)), "h");
}
}

@@ -50,2 +66,5 @@ else {

newTimeRelative = new Intl.RelativeTimeFormat(locale, options).format(newInterval, 'minute');
if (type === 'short') {
newTimeRelative = "".concat(Math.abs(Math.round(newInterval)), "m");
}
}

@@ -52,0 +71,0 @@ }

@@ -1,5 +0,6 @@

var relative = function (dateValue, timeZone, locale, options, defaultValue) {
var relative = function (dateValue, timeZone, locale, options, type) {
if (timeZone === void 0) { timeZone = 'utc'; }
if (locale === void 0) { locale = 'en-US'; }
if (options === void 0) { options = {}; }
if (type === void 0) { type = 'long'; }
var nowDate = new Date();

@@ -11,3 +12,6 @@ var valDate = new Date(dateValue);

var seconds = Math.round((valDate.valueOf() - nowDate.valueOf()) / 1000);
var newTimeRelative = new Intl.RelativeTimeFormat(locale, options).format(Math.round(seconds), 'second');
var newTimeRelative = new Intl.RelativeTimeFormat(locale, options).format(seconds, 'second');
if (type === 'short') {
newTimeRelative = "".concat(Math.abs(Math.round(seconds)), "s");
}
var interval = seconds / 31536000;

@@ -17,2 +21,5 @@ if (Math.abs(interval) > 1) {

newTimeRelative = new Intl.RelativeTimeFormat(locale, options).format(newInterval, 'year');
if (type === 'short') {
newTimeRelative = "".concat(Math.abs(Math.round(newInterval)), "y");
}
}

@@ -24,2 +31,5 @@ else {

newTimeRelative = new Intl.RelativeTimeFormat(locale, options).format(newInterval, 'month');
if (type === 'short') {
newTimeRelative = "".concat(Math.abs(Math.round(newInterval)), "mo");
}
}

@@ -31,2 +41,5 @@ else {

newTimeRelative = new Intl.RelativeTimeFormat(locale, options).format(newInterval, 'day');
if (type === 'short') {
newTimeRelative = "".concat(Math.abs(Math.round(newInterval)), "d");
}
}

@@ -38,2 +51,5 @@ else {

newTimeRelative = new Intl.RelativeTimeFormat(locale, options).format(newInterval, 'hour');
if (type === 'short') {
newTimeRelative = "".concat(Math.abs(Math.round(newInterval)), "h");
}
}

@@ -45,2 +61,5 @@ else {

newTimeRelative = new Intl.RelativeTimeFormat(locale, options).format(newInterval, 'minute');
if (type === 'short') {
newTimeRelative = "".concat(Math.abs(Math.round(newInterval)), "m");
}
}

@@ -47,0 +66,0 @@ }

@@ -1,1 +0,1 @@

var time=function(e){"use strict";return e.hoursInBetween=function(e,t){var a=new Date(e),n=new Date(t),r=Math.abs(Number(a.getTime())-Number(n.getTime()));return Number((r/36e5).toFixed(0))},e.relative=function(e,t,a,n,r){void 0===t&&(t="utc"),void 0===a&&(a="en-US"),void 0===n&&(n={});var o=new Date,i=new Date(e);"utc"!==t&&(i=new Date(new Date(e).toJSON()));var m=Math.round((i.valueOf()-o.valueOf())/1e3),u=new Intl.RelativeTimeFormat(a,n).format(Math.round(m),"second"),l=m/31536e3;if(Math.abs(l)>1){var v=Math.round(l);u=new Intl.RelativeTimeFormat(a,n).format(v,"year")}else if(l=m/2592e3,Math.abs(l)>1){v=Math.round(l);u=new Intl.RelativeTimeFormat(a,n).format(v,"month")}else if(l=m/86400,Math.abs(l)>1){v=Math.round(l);u=new Intl.RelativeTimeFormat(a,n).format(v,"day")}else if(l=m/3600,Math.abs(l)>1){v=Math.round(l);u=new Intl.RelativeTimeFormat(a,n).format(v,"hour")}else if(l=m/60,Math.abs(l)>1){v=Math.round(l);u=new Intl.RelativeTimeFormat(a,n).format(v,"minute")}return u},Object.defineProperty(e,"__esModule",{value:!0}),e}({});
var time=function(t){"use strict";return t.hoursInBetween=function(t,e){var a=new Date(t),n=new Date(e),o=Math.abs(Number(a.getTime())-Number(n.getTime()));return Number((o/36e5).toFixed(0))},t.relative=function(t,e,a,n,o){void 0===e&&(e="utc"),void 0===a&&(a="en-US"),void 0===n&&(n={}),void 0===o&&(o="long");var r=new Date,h=new Date(t);"utc"!==e&&(h=new Date(new Date(t).toJSON()));var i=Math.round((h.valueOf()-r.valueOf())/1e3),u=new Intl.RelativeTimeFormat(a,n).format(i,"second");"short"===o&&(u="".concat(Math.abs(Math.round(i)),"s"));var m=i/31536e3;if(Math.abs(m)>1){var s=Math.round(m);u=new Intl.RelativeTimeFormat(a,n).format(s,"year"),"short"===o&&(u="".concat(Math.abs(Math.round(s)),"y"))}else if(m=i/2592e3,Math.abs(m)>1){s=Math.round(m);u=new Intl.RelativeTimeFormat(a,n).format(s,"month"),"short"===o&&(u="".concat(Math.abs(Math.round(s)),"mo"))}else if(m=i/86400,Math.abs(m)>1){s=Math.round(m);u=new Intl.RelativeTimeFormat(a,n).format(s,"day"),"short"===o&&(u="".concat(Math.abs(Math.round(s)),"d"))}else if(m=i/3600,Math.abs(m)>1){s=Math.round(m);u=new Intl.RelativeTimeFormat(a,n).format(s,"hour"),"short"===o&&(u="".concat(Math.abs(Math.round(s)),"h"))}else if(m=i/60,Math.abs(m)>1){s=Math.round(m);u=new Intl.RelativeTimeFormat(a,n).format(s,"minute"),"short"===o&&(u="".concat(Math.abs(Math.round(s)),"m"))}return u},Object.defineProperty(t,"__esModule",{value:!0}),t}({});
{
"name": "alga-js",
"version": "0.1.0-stone-6",
"version": "0.1.0-stone-7",
"description": "Alga.js is a JavaScript helper to help build UI components by using any of modern web frameworks or libraries",

@@ -5,0 +5,0 @@ "module": "./dist/alga.min.js",

export * from './separatorNumber.js'
export * from './percentageNumber.js'
export * from './unitNumber.js'
export * from './spaceNumber.js'

@@ -6,3 +6,3 @@ import { isBefore } from '../date/isDate'

export const relative = (dateValue: Date | string | number, timeZone: string = 'utc', locale: string = 'en-US', options: any = {}, defaultValue: string = 'new') => {
export const relative = (dateValue: Date | string | number, timeZone: string = 'utc', locale: string = 'en-US', options: any = {}, type: string = 'long') => {
const nowDate: Date = new Date()

@@ -15,3 +15,6 @@ let valDate: Date = new Date(dateValue)

let seconds = Math.round((valDate.valueOf() - nowDate.valueOf()) / 1000)
let newTimeRelative = new Intl.RelativeTimeFormat(locale, options).format(Math.round(seconds), 'second')
let newTimeRelative = new Intl.RelativeTimeFormat(locale, options).format(seconds, 'second')
if(type === 'short') {
newTimeRelative = `${Math.abs(Math.round(seconds))}s`
}

@@ -22,2 +25,5 @@ let interval = seconds / 31536000

newTimeRelative = new Intl.RelativeTimeFormat(locale, options).format(newInterval, 'year')
if(type === 'short') {
newTimeRelative = `${Math.abs(Math.round(newInterval))}y`
}
} else {

@@ -28,2 +34,5 @@ interval = seconds / 2592000

newTimeRelative = new Intl.RelativeTimeFormat(locale, options).format(newInterval, 'month')
if(type === 'short') {
newTimeRelative = `${Math.abs(Math.round(newInterval))}mo`
}
} else {

@@ -34,2 +43,5 @@ interval = seconds / 86400;

newTimeRelative = new Intl.RelativeTimeFormat(locale, options).format(newInterval, 'day')
if(type === 'short') {
newTimeRelative = `${Math.abs(Math.round(newInterval))}d`
}
} else {

@@ -40,2 +52,5 @@ interval = seconds / 3600;

newTimeRelative = new Intl.RelativeTimeFormat(locale, options).format(newInterval, 'hour')
if(type === 'short') {
newTimeRelative = `${Math.abs(Math.round(newInterval))}h`
}
} else {

@@ -46,2 +61,5 @@ interval = seconds / 60;

newTimeRelative = new Intl.RelativeTimeFormat(locale, options).format(newInterval, 'minute')
if(type === 'short') {
newTimeRelative = `${Math.abs(Math.round(newInterval))}m`
}
}

@@ -48,0 +66,0 @@ }

export * from './separatorNumber.js';
export * from './percentageNumber.js';
export * from './unitNumber.js';
export * from './spaceNumber.js';

@@ -1,1 +0,1 @@

export declare const relative: (dateValue: Date | string | number, timeZone?: string, locale?: string, options?: any, defaultValue?: string) => string;
export declare const relative: (dateValue: Date | string | number, timeZone?: string, locale?: string, options?: any, type?: string) => string;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc