All Projects → coffee-cup → count.macro

coffee-cup / count.macro

Licence: MIT license
Babel macro for counting number of lines or words in files at compile time

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to count.macro

Data-Structure-Algorithm-Programs
This Repo consists of Data structures and Algorithms
Stars: ✭ 464 (+2220%)
Mutual labels:  count
CircularCountdown
Android library to create a circular countdown, fully written in Kotlin
Stars: ✭ 24 (+20%)
Mutual labels:  count
vue-countup
A plugin to count up to a figure using Vue.js
Stars: ✭ 42 (+110%)
Mutual labels:  count
HurdleDMR.jl
Hurdle Distributed Multinomial Regression (HDMR) implemented in Julia
Stars: ✭ 19 (-5%)
Mutual labels:  count
CounterView
一个数字变化效果的计数器视图控件
Stars: ✭ 38 (+90%)
Mutual labels:  count
countapi-js
Wrapper for CountAPI using promises.
Stars: ✭ 37 (+85%)
Mutual labels:  count
MD REncoder
Rotary Encoder Library
Stars: ✭ 25 (+25%)
Mutual labels:  count
CorBinian
CorBinian: A toolbox for modelling and simulating high-dimensional binary and count-data with correlations
Stars: ✭ 15 (-25%)
Mutual labels:  count
LinqBenchmarks
Benchmarking LINQ and alternative implementations
Stars: ✭ 138 (+590%)
Mutual labels:  count
vue-countable
✍️ Vue binding for countable.js. Provides real-time paragraph, sentence, word, and character counting.
Stars: ✭ 25 (+25%)
Mutual labels:  count
linec
🍬一个高颜值命令行统计代码行数的计数器。(counts lines of code)
Stars: ✭ 121 (+505%)
Mutual labels:  count
sp who3
The sp_who3 stored procedure is a custom and open source alternative to the sp_who system stored procedures available in SQL Server.
Stars: ✭ 49 (+145%)
Mutual labels:  count
subtlex-word-frequencies
A list of words from the SUBTLEX movie subtitles corpus, sorted by frequency.
Stars: ✭ 25 (+25%)
Mutual labels:  count
recount
R package for the recount2 project. Documentation website: http://leekgroup.github.io/recount/
Stars: ✭ 40 (+100%)
Mutual labels:  count

count.macro

Babel Macro

Count lines or words in files at build time

Installation

count.macro is a Babel macro. This will work out of the box with CRA, Gatsby, and Next.

npm install --save-dev count.macro

Usage

Line and word information is based on the source file, not the output file.

For example, this file

import { lines, linesIn, words, wordsIn } from "count.macro";

console.log(`This file has ${lines} lines`);
console.log(`lines.txt has ${linesIn("./lines.txt")}`);

console.log(`This file has ${words} words`);
console.log(`words.txt has ${wordsIn("./words.txt")}`);

will be transpiled to

console.log(`This file has ${7} lines`);
console.log(`lines.txt has ${100}`);
console.log(`This file has ${25} words`);
console.log(`words.txt has ${1000}`);

Named Exports

  • lines is a number that will be transpiled to number of lines in current file
  • linesIn is a function that takes a filename as an argument. The call will be replaced with the number of lines in the file (relative to the current file).
  • words is a number that will be transpiled to number of words in current file.
  • wordsIn is a function that takes a filename as an argument. The call will be replaced with the number of words in the file (relative to the current file).

CodeSandbox Example

Edit count.macro

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].