Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const cond = conds => x => {
const c = conds.find (y => y[0] (x));
if (c !== undefined) {
return c[1] (x);
}
throw new Error (`No predicate was satisfied for ${x}`);
};
// stripNamespace :: String -> String
const stripNamespace = memoize (xs => xs.split ('/').pop ());
// name :: { name :: a } -> a
const name = S.prop ('name');
// text :: { text :: a } -> a
const text = S.prop ('text');
// spellNumber :: Number -> String
const spellNumber = x => ({
1: 'one',
2: 'two',
3: 'three',
4: 'four',
5: 'five',
6: 'six',
7: 'seven',
8: 'eight',
9: 'nine',
}[x] || x.toString ());
// ----------------------------------------------------------------------------
//
(acc => curr => S.insert (curr[0]) (curr[1]) (acc))
({});
// cond :: Array (Array2 (a -> Boolean) (a -> b)) -> a -> b
const cond = conds => x => {
const c = conds.find (y => y[0] (x));
if (c !== undefined) {
return c[1] (x);
}
throw new Error (`No predicate was satisfied for ${x}`);
};
// stripNamespace :: String -> String
const stripNamespace = memoize (xs => xs.split ('/').pop ());
// name :: { name :: a } -> a
const name = S.prop ('name');
// text :: { text :: a } -> a
const text = S.prop ('text');
// spellNumber :: Number -> String
const spellNumber = x => ({
1: 'one',
2: 'two',
3: 'three',
4: 'four',
5: 'five',
6: 'six',
7: 'seven',
8: 'eight',
9: 'nine',
}[x] || x.toString ());
};
// indexTypeClasses :: Array TypeClass -> TypeClassMap
const indexTypeClasses = memoize (indexBy (S.pipe ([
name,
stripNamespace,
])));
// ----------------------------------------------------------------------------
//
// Types
//
// ----------------------------------------------------------------------------
// children :: { children :: Array a } -> Array a
const children = S.prop ('children');
// firstChild :: { children :: NonEmpty (Array a) } -> a
const firstChild = x => children (x)[0];
// typeEq :: String -> Object -> Boolean
const typeEq = propEq ('type');
// hasChildren :: { children :: Array a } -> Boolean
const hasChildren = x => !isEmpty (children (x));
// assertTypeArity :: Type -> Array Type -> Undefined !
const assertTypeArity = type => argTypes => {
const expected = type.keys.length;
const actual = argTypes.length;
if (expected !== actual) {
throw new TypeError (
const writeFile = S.curry2((file, data) =>
new LazyEither(resolve => {
fs.writeFile(file,
data,
err => resolve(err != null ? S.Left(err) : S.Right('Write successful')))
})
)
const getStats =
S.pipe([readDir,
S.map(S.filter(S.test(/[.]js$/))),
S.chain(S.traverse(LazyEither, readFile)),
S.map(String),
S.map(S.matchAll(/require[(][^)]+[)]/g)),
S.map(S.prop('length')),
S.map(String),
S.map(S.concat('Total requires: ')),
S.chain(writeFile('stats.txt'))])
getStats(__dirname).value(console.log)
//getStats('blablah').value(console.log)
metaData,
},
location,
}))
));
});
fetchAllDocIds()
.then(docIds => docIds.reduce((docs, id) => ({
...docs,
[id]: fetchDocFolders(id),
}), {}))
.then(promiseAllProps)
.then(justs)
.then(filter (pipe([
map(prop('id')),
elem(process.env.DROPBOX_PAPER_DIRECTORY_ID),
])))
.then(Object.entries)
.then(appendMetaData)
.then(reject(isDeletedDoc))
.then(appendDocContent)
.then(saveDocsLocally)
.catch(console.error);
const {
chain,
curry2,
compose,
gets,
match,
map,
Nothing,
prop,
pipe,
reduce,
} = require('sanctuary');
const foldersToPath = pipe([
map (compose (kebabCaseIt) (prop('name')) ),
reduce (curry2(path.join)) (''),
]);
const isPermissionError = pipe([
gets (Boolean) (['body', 'error_summary']),
chain(match(/insufficient_permissions/)),
]);
const fetchPaginatedDocIds = apiFetch => previousDocIds => ({
body: { doc_ids: docIds, cursor, has_more: hasMore },
}) =>
hasMore
? apiFetch('/docs/list/continue', {
body: { cursor },
})
.then(fetchPaginatedDocIds (apiFetch) (previousDocIds.concat(docIds)))
const {
chain,
compose,
find,
pipe,
prop,
map,
match,
} = require('sanctuary');
const getDropboxDocumentLocation = pipe([
match(/paper\.dropbox\.com\/doc\/.+--\S{26}-(\w{21})/),
chain(match => match.groups[0]),
chain(urlId => find (doc => doc.id === urlId) (documentsMetaData)),
map(compose (path.parse) (prop('location'))),
]);
module.exports = {
title: 'Playbook',
themeConfig: {
sidebar: generateSidebar(documentsMetaData),
},
extendMarkdown: markdown => {
markdown.use(markdownItForInline, 'internal-link', 'link_open', (tokens, index) => {
const token = tokens[index];
pipe([
getDropboxDocumentLocation,
map(location => {
token.attrSet(
'href',
(xs => x => {
const typeVarName = S.prop ('typevar') (x);
const newTypeClassName = S.prop ('typeclass') (x);
const typeVarClasses = S.fromMaybe
([])
(S.get
(S.is ($.Array ($.String)))
(typeVarName)
(xs));
return S.insert
(typeVarName)
(S.append (newTypeClassName) (typeVarClasses))
(xs);
})
({});
(xs => x => {
const typeVarName = S.prop ('typevar') (x);
const newTypeClassName = S.prop ('typeclass') (x);
const typeVarClasses = S.fromMaybe
([])
(S.get
(S.is ($.Array ($.String)))
(typeVarName)
(xs));
return S.insert
(typeVarName)
(S.append (newTypeClassName) (typeVarClasses))
(xs);
})
({});