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

line-controller

v0.0.1

Published

Line Unit Editor for Multiple Files

Downloads

12

Readme

line-controller.js

Line Unit Editor for Multiple Files

Install

npm install line-controller

Usage

import line-controller

const { insertLine, deleteLine, updateLine, selectLine } = require('line-controller');

image

🖋 insertLine

📎 example

/**
 * @description targetDir에 있는 파일들 중 파일명에 targetWord가 포함되는 파일에 원하는 line들을 삽입한다.
 * @param {String} targetDir 원하는 디렉토리의 경로 ex) 'files/'
 * @param {String} targetWord 파일명에 포함된 원하는 단어
 * @param {Number} targetLine 삽입하고 싶은 라인 번호
 * @param  {...String} lines 삽입하고 싶은 문자열 (여러 문자열 가능)
 * @return {Promise} 수행된 프로미스. resolve에 삽입된 결과 파일의 내용이 담긴다.
 */

insertLine('files/', 'javascript', 8, 'tag:', '\t- JavaScript');

🔎 before

---
layout: post
title: "JavaScript 1"
subtitle: "JavaScript Study"
date: 2020-08-28 09:51:12
author: kwon
categories: JavaScript
---
# JavaScript 1

🔎 after

---
layout: post
title: "JavaScript 1"
subtitle: "JavaScript Study"
date: 2020-08-28 09:51:12
author: kwon
categories: JavaScript
tag:
	- JavaScript
---
# JavaScript 1

⌫deleteLine

📎 example

/**
 * @description targetDir에 있는 파일들 중 파일명에 targetWord가 포함되는 파일에 원하는 line을 지운다.
 * @param {String} targetDir 원하는 디렉토리의 경로 ex) 'files/'
 * @param {String} targetWord 파일명에 포함된 원하는 단어
 * @param {Number} targetLine 삭제하고 싶은 라인 번호
 * @param {Number} deleteCount 삭제를 원하는 라인 수 (default = 1) optional
 * @return {Promise} 수행된 프로미스. resolve에 목표 라인이 제거된 결과 파일의 내용이 담긴다.
 */

deleteLine('files/', 'javascript', 8, 2);

🔎 before

---
layout: post
title: "JavaScript 1"
subtitle: "JavaScript Study"
date: 2020-08-28 09:51:12
author: kwon
categories: JavaScript
tag:
	- JavaScript
---
# JavaScript 1

🔎 after

---
layout: post
title: "JavaScript 1"
subtitle: "JavaScript Study"
date: 2020-08-28 09:51:12
author: kwon
categories: JavaScript
---
# JavaScript 1

✏️ updateLine

📎 example

(async () => {
    const result = await updateLine('files/', 'javascript', 3, 'title: "updated JavaScript 1"');
    console.log(result);
})();

🔎 before

---
layout: post
title: "JavaScript 1"
subtitle: "JavaScript Study"
date: 2020-08-28 09:51:12
author: kwon
categories: JavaScript
---
# JavaScript 1

🔎 after(output)

---
layout: post
title: "updated JavaScript 1"
subtitle: "JavaScript Study"
date: 2020-08-28 09:51:12
author: kwon
categories: JavaScript
---
# JavaScript 1

📌 selectLine

📎 example

/**
 * @description fileName 파일의 원하는 line을 읽어온다.
 * @param {String} fileName 읽고자 하는 파일의 경로 ex) 'files/abc.txt'
 * @param {Number} targetLine 읽고 싶은 시작 line 번호
 * @param {Number} selectCount 읽고자 하는 line 수 (default = 1) optional
 * @return {String} 읽어온 결과 문자열
 */

const result = selectLine('/files/javascript1.md', 2, 3);
console.log(result);

🔎 output

layout: post
title: "updated JavaScript 1"
subtitle: "JavaScript Study"