npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@woowacourse/mission-utils

v2.2.0

Published

![npm](https://img.shields.io/npm/v/@woowacourse/mission-utils) [![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://github.com/facebook/jest)

Downloads

5,704

Readme

mission-utils

npm tested with jest

Install

with CDN

  1. 스크립트 삽입하기
<script src="https://cdn.jsdelivr.net/npm/@woowacourse/[email protected]/dist/mission-utils.min.js"></script>
<script type="module" src="index.js"></script>
  • index.html에 해당 스크립트 태그를 삽입해주세요.
  • 유틸 라이브러리의 경우 어플리케이션 스크립트 이전에 작성해야 합니다.
  1. 유틸 사용하기
// example
console.log(MissionUtils.Random.pickNumberInList([1, 2, 3]));
  • 스크립트 태그로 삽입된 경우 전역에 할당되어 MissionUtils.[util] 형태로 사용할 수 있습니다.

with npm

  1. 모듈 다운로드
npm i @woowacourse/mission-utils
  1. 모듈 사용하기

ES Modules 방식으로 사용하는 경우

import { MissionUtils } from "@woowacourse/mission-utils";

console.log(MissionUtils.Random.pickNumberInList([1, 2, 3]));

CommonJS 방식으로 사용하는 경우

const MissionUtils = require("@woowacourse/mission-utils");

console.log(MissionUtils.Random.pickNumberInList([1, 2, 3]));

Features

Console

readLine(query, callback)

주어진 질문을 화면에 출력하고, 사용자가 답변을 입력할 때까지 기다린 다음 입력된 답변을 인수로 전달하는 콜백 함수를 호출한다.

Console.readLine('닉네임을 입력해주세요.', (answer) => {
  console.log(`닉네임: ${answer}`);
});

readLineAsync(query)

주어진 질문을 화면에 출력하고, 사용자가 입력한 답변을 Promise를 통해 반환한다.

async function getUsername() {
  try {
    const username = await Console.readLineAsync('닉네임을 입력해주세요.');
  } catch (error) {
    // reject 되는 경우
  }
}

print(message)

주어진 문자열을 콘솔에 출력한다.

Console.print('안녕하세요.');

Random

pickNumberInRange(startInclusive, endInclusive)

숫자 범위를 지정하면 시작 또는 끝 숫자를 포함하여 범위의 숫자를 반환한다.

Random.pickNumberInRange(1, 10); // 1
Random.pickNumberInRange(1, 10); // 10
Random.pickNumberInRange(1, 10); // 4
Random.pickNumberInRange(1, 10); // 5

pickNumberInList(array)

목록에 있는 숫자 중 하나를 반환한다.

Random.pickNumberInList([1, 3, 10]); // 1
Random.pickNumberInList([1, 3, 10]); // 10
Random.pickNumberInList([1, 3, 10]); // 3

pickUniqueNumbersInRange(startInclusive, endInclusive, count)

숫자 범위 내에서 지정된 개수만큼 겹치지 않는 숫자를 반환한다.

Random.pickUniqueNumbersInRange(1, 10, 2); // [1, 2]
Random.pickUniqueNumbersInRange(1, 10, 5); // [1, 10, 7, 8, 5]

shuffle(array)

무작위로 섞인 새 목록을 반환한다.

Random.shuffle([1, 2, 3, 4, 5]); // [2, 4, 1, 3, 5]

Contributors