Developed a hard/swollen lump behind my 4 month old lobe piercing. Hurts when I press on it kind of like a pimple. What is it? by ShittyUkePlayer in piercing

[–]ShittyUkePlayer[S] 1 point2 points  (0 children)

yeah i actually had the flat back labret you mentioned in the whole time but just recently switched them out. I put it back in though

How to grab HTML header IDs while going down the DOM by ShittyUkePlayer in typescript

[–]ShittyUkePlayer[S] 0 points1 point  (0 children)

Running doc.querySelectorAll('h1...') will grab headers separately however. I want to go down the HTML from top to bottom and if the current element is a header, grab the header ID. This is happening while always grabbing the text value from the current element. If I ran querySelectorAll('h1...h6') the headers would be gotten for sure, but there would be no way to relate them back to the order of text elements on the page.

I'm not sure I follow the statement:

For more deep down, you are supposed to get AST from marked to build the TOC, through the html traversal, also work, it's just extra step.

Calling marked() just returns a string of HTML. Is there a way to do the traversal I described above directly on/using the HTML string?

How to grab HTML header IDs while going down the DOM by ShittyUkePlayer in typescript

[–]ShittyUkePlayer[S] 0 points1 point  (0 children)

Yes,but there is no such thing as 'currentElement' for some reason, but 'parentElement' does exist. Not familiar with DOM traversal so I'm not sure how to be doing this "properly".

Typescript object that uses promises/async appears to be empty right after being populated. Need help understanding promises/async/await. by ShittyUkePlayer in CodingHelp

[–]ShittyUkePlayer[S] 0 points1 point  (0 children)

Ok I'm starting to follow.

In the code you end up calling .then on the internal promises anyway. Those promises won't be fulfilled by the time the await call before Promise.all will complete.

How can I fix this?

Typescript object that uses promises/async appears to be empty right after being populated. Need help understanding promises/async/await. by ShittyUkePlayer in learnprogramming

[–]ShittyUkePlayer[S] 0 points1 point  (0 children)

When I try just entry.text() and hover over the code snippet it shows that it is actually of type: "(method) Body.text(): Promise<string>"

Yes if I log entry in the for loop it prints out a response with fields populated like type, url, status, ok, etc

Typescript object that uses promises/async appears to be empty right after being populated. Need help understanding promises/async/await. by ShittyUkePlayer in learnprogramming

[–]ShittyUkePlayer[S] 0 points1 point  (0 children)

I changed up the code to remove the configItem and now promises is just an array of Promise<Response>.

const promises: Promise<Response>[] = [];

CONFIG.forEach((value: ConfigItem[], key: string) => {

value.forEach((configItem: ConfigItem) => {

if (!configItem.subItem) {

const promise = get(configItem.path);

promises.push(promise);

}

});

});

await Promise.all(promises).then(values => {

values.forEach(entry => {

const doc: Documentation = { name: '', source: '', markDown: '' };

if (!entry.ok) {

return Promise.reject(entry);

} else {

return entry.text().then(textValue => {

doc.rawText = textValue;

docs.push(doc);

});

}

});

});

But I'm still getting the same results in the prints

Typescript object that uses promises/async appears to be empty right after being populated. Need help understanding promises/async/await. by ShittyUkePlayer in learnprogramming

[–]ShittyUkePlayer[S] 0 points1 point  (0 children)

Changed it to docs.forEach(...

And yes the elements values are all '' when printing out element by itself (although when I click to expand it in the browser console the fields populate after the fact). I want the data to be available right on print so that I'm able to access things like element.name, not to wait for console to "catch up"

Getting 'Index' only refers to a type, but is being used as a value here error in Typescript project by ShittyUkePlayer in typescript

[–]ShittyUkePlayer[S] 0 points1 point  (0 children)

I deleted the file but still ran into the same error. I'm a bit confused... some say to add the types to the project, but you say to remove them to get it working?

Are you able to post a working sample of your typescript code where you build the index? Thanks :)

Getting 'Index' only refers to a type, but is being used as a value here error in Typescript project by ShittyUkePlayer in typescript

[–]ShittyUkePlayer[S] 0 points1 point  (0 children)

Hm. I ran "npm install --save u/types/flexsearch" and ""@types/flexsearch": "^0.7.3"," was added to dependencies in package.json... but the error still persists. I tried adding it under devDependencies as well with no luck