Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Library to get first day of week.
getWeekStartByRegion('MAC'); // 0
getWeekStartByLocale('arq'); // 6
The library is based on the following data from Unicode (especially from Common Locale Data Repository) and from ISO:
There are 2 variants of the library having identical API:
main
- uses base mapping of language code to country code from langRegionMap.full
- uses full mapping of language code to country code from fullLangRegionMap.langRegionMap contains only main language codes. It is data subset from fullLangRegionMap.
npm install weekstart
bower install weekstart
Use dist/main.js
or dist/min/main.js
(minified version).
Use dist/full.js
or dist/min/full.js
(minified version) when you need full locale data.
import {getWeekStartByLocale, getWeekStartByRegion} from 'weekstart';
If you need full data:
import {getWeekStartByLocale, getWeekStartByRegion} from 'weekstart/full';
const getWeekStartByLocale = require('weekstart').getWeekStartByLocale;
const getWeekStartByRegion = require('weekstart').getWeekStartByRegion;
If you need full data:
const getWeekStartByLocale = require('weekstart/full').getWeekStartByLocale;
const getWeekStartByRegion = require('weekstart/full').getWeekStartByRegion;
define(['path/to/dist/main.js'], function(weekstart) {
const getWeekStartByLocale = weekstart.getWeekStartByLocale;
const getWeekStartByRegion = weekstart.getWeekStartByRegion;
});
If you need full data:
define(['path/to/dist/full.js'], function(weekstart) {
const getWeekStartByLocale = weekstart.getWeekStartByLocale;
const getWeekStartByRegion = weekstart.getWeekStartByRegion;
});
<!-- Use bower_components/weekstart/dist/main.js and bower_components/weekstart/dist/full.js if the library was installed by Bower -->
<script type="text/javascript" src="path/to/dist/main.js"></script>
<script type="text/javascript">
// weekstart is available via weekstart field of window object
const getWeekStartByLocale = weekstart.getWeekStartByLocale;
const getWeekStartByRegion = weekstart.getWeekStartByRegion;
</script>
If you need full data use path/to/dist/full.js
instead of path/to/dist/main.js
.
getWeekStartByRegion('dj'); // 6
getWeekStartByRegion('No'); // 1
getWeekStartByRegion('CAN'); // 0
getWeekStartByRegion(462); // 5
getWeekStartByLocale('Jam'); // 0
getWeekStartByLocale('Fa'); // 6
getWeekStartByLocale('vi'); // 1
getWeekStartByLocale('es_MX'); // 0
getWeekStartByLocale('az-Arab-IRN'); // 6
In the following examples results are given for the function from full.js
.
The same calls for the function from main.js
will return 1
.
getWeekStartByLocale('CCP'); // 0
getWeekStartByLocale('UZ-arab'); // 6
Return first day of week for locale identifier: 0 - Sunday, 1 - Monday, 2 - Tuesday, 3 - Wednesday, 4 - Thursday, 5 - Friday, 6 - Saturday.
Return first day of week for country/region code: 0 - Sunday, 1 - Monday, 2 - Tuesday, 3 - Wednesday, 4 - Thursday, 5 - Friday, 6 - Saturday.
See docs
for details.
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.
Licensed under the MIT license.
FAQs
Library to get first day of week.
The npm package weekstart receives a total of 60,228 weekly downloads. As such, weekstart popularity was classified as popular.
We found that weekstart demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.