CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes45downloads
readme.md66 linesDownload Raw Back to code-excerpt
1# code-excerpt ![test](https://github.com/vadimdemedes/code-excerpt/workflows/test/badge.svg)2 3> Extract code excerpts4 5## Install6 7```8$ npm install --save code-excerpt9```10 11## Usage12 13```js14import codeExcerpt from 'code-excerpt';15 16const source = `17'use strict';18 19function someFunc() {}20 21module.exports = () => {22	const a = 1;23	const b = 2;24	const c = 3;25 26	someFunc();27};28`.trim();29 30const excerpt = codeExcerpt(source, 5);31//=> [32//	{line: 2, value: ''},33//	{line: 3, value: 'function someFunc() {}'},34//	{line: 4, value: ''},35//	{line: 5, value: 'module.exports = () => {'},36//	{line: 6, value: '  const a = 1;'},37//	{line: 7, value: '  const b = 2;'},38//	{line: 8, value: '  const c = 3;'}39// ]40```41 42## API43 44### codeExcerpt(source, line, [options])45 46#### source47 48Type: `string`49 50Source code.51 52#### line53 54Type: `number`55 56Line number to extract excerpt for.57 58#### options59 60##### around61 62Type: `number`<br>63Default: `3`64 65Number of surrounding lines to extract.66 
basant307/AI_Governance_Project · CoolFace